function votingapi_actions_set_form in Voting API 5
2 string references to 'votingapi_actions_set_form'
- votingapi_actions_admin_add_page in ./votingapi_actions_ui.inc
- votingapi_actions_admin_edit_page in ./votingapi_actions_ui.inc
File
- ./votingapi_actions_ui.inc, line 267
Code
function votingapi_actions_set_form($set, $form_values = NULL) {
$form = array();
$form['#multistep'] = TRUE;
$form['#redirect'] = FALSE;
$form['#tree'] = TRUE;
if (isset($form_values)) {
if (is_array($form_values['conditions']['existing'])) {
foreach ($form_values['conditions']['existing'] as $condition) {
$set['conditions'][] = $action['value'];
}
}
if ($form_values['op'] == t('Add condition')) {
$set['conditions'][] = array(
'new' => TRUE,
'handler' => $form_values['conditions']['add']['condition_type'],
);
}
unset($form_values['conditions']['add']);
if (is_array($form_values['actions']['existing'])) {
foreach ($form_values['actions']['existing'] as $action) {
$set['actions'][] = $action['value'];
}
}
if ($form_values['op'] == t('Add action')) {
$set['actions'][] = $form_values['actions']['add']['action_type'];
}
}
$form['vasid'] = array(
'#type' => 'hidden',
'#value' => $set['vasid'],
);
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Set name'),
'#required' => TRUE,
'#description' => t('A unique name for this set. Stick to lowercase letters, and use underscores instead of spaces.'),
'#default_value' => $set['name'],
);
if (isset($set['parent'])) {
$form['parent'] = array(
'#type' => 'hidden',
'#value' => $set['parent'],
);
$form['required'] = array(
'#type' => 'checkbox',
'#title' => t('This set is required.'),
'#return_value' => 1,
'#default_value' => $set['required'],
'#description' => t("If this box is checked, this set's conditions must be passed before the parent set's actions can execute."),
);
}
else {
$form['content_type'] = array(
'#type' => 'hidden',
'#value' => 'node',
);
$form['required'] = array(
'#type' => 'hidden',
'#value' => TRUE,
);
}
$form['weight'] = array(
'#type' => 'hidden',
'#value' => 0,
);
$form['condition_mask'] = array(
'#type' => 'select',
'#title' => t("To execute this set's actions"),
'#options' => array(
'AND' => t('...All conditions must be true'),
'OR' => t('...At least one condition must be true'),
),
'#default_value' => isset($set['condition_mask']) ? $set['condition_mask'] : 'AND',
);
$form['conditions'] = array(
'#type' => 'fieldset',
'#title' => t('Conditions'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#description' => t('These conditions determine whether the actions in this set are executed.'),
);
foreach ($set['conditions'] as $condition) {
$form['conditions'][] = votingapi_actions_condition_form($condition);
}
$form['conditions']['add']['#weight'] = 100;
$form['conditions']['add']['#theme'] = 'votingapi_actions_add_condition';
$form['conditions']['add']['condition_type'] = array(
'#type' => 'select',
'#options' => _votingapi_actions_condition_types(),
);
$form['conditions']['add']['add_condition'] = array(
'#type' => 'button',
'#value' => t('Add condition'),
);
$form['actions'] = array(
'#type' => 'fieldset',
'#title' => t('Actions'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#description' => t('If the conditions above pass, this list of actions will execute.'),
);
$form['actions']['existing']['#weight'] = 0;
foreach ($set['actions'] as $action) {
$form['actions']['existing'][] = votingapi_actions_action_form($action);
}
$form['actions']['add']['#weight'] = 100;
$form['actions']['add']['#theme'] = 'votingapi_actions_add_action';
$form['actions']['add']['action_type'] = array(
'#type' => 'select',
'#options' => _votingapi_actions_list(),
);
$form['actions']['add']['add_action'] = array(
'#type' => 'button',
'#value' => t('Add action'),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
return $form;
}