function votingapi_actions_set_form in Voting API 5
2 string references to 'votingapi_actions_set_form'
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;
// Here we look for incoming form values and modify the set as needed.
if (isset($form_values)) {
// Populate the set's conditions from the incoming 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']);
// Populate the set's actions from the form values.
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'],
);
/*
$form['description'] = array(
'#type' => 'textarea',
'#title' => t('Description'),
'#description' => t("A description of this action set's operations. You'll appreciate filling this out later."),
'#default_value' => $set['description'],
);
*/
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['content_type'] = array(
'#type' => 'select',
'#title' => t('Content type'),
'#options' => array('node' => t('Nodes'), 'comment' => t('Comments')),
'#default_value' => isset($set['content_type']) ? $set['content_type'] : 'node',
'#required' => TRUE,
'#description' => t('The type of content this action set will apply to.')
);
*/
$form['required'] = array(
'#type' => 'hidden',
'#value' => TRUE,
);
}
$form['weight'] = array(
'#type' => 'hidden',
'#value' => 0,
);
/*
$form['weight'] = array(
'#type' => 'weight',
'#title' => t('Weight'),
'#default_value' => $set['weight'],
);
*/
$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',
);
// Conditions
$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'),
);
// Actions
$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;
}