function rules_forms_action_set_options in Rules Forms Support 7
Action: Set multiple value options of a form element.
Note: For multiple option values each key value pair is on its own line and formatted key|value.
Parameters
mixed $form: A reference to the form array of the form for which the event was triggered.
string $element_id: The element ID of the element being checked in the form of element_type:element_id.
string $value: A value to assign to the element's #options attribute. This value is split into an array.
1 string reference to 'rules_forms_action_set_options'
- rules_forms_rules_action_info in ./
rules_forms.rules.inc - Implements hook_rules_action_info().
File
- includes/
rules_forms.eval.inc, line 524 - Evaluation functions for Rules Forms module.
Code
function rules_forms_action_set_options($form, $element_id, $value) {
$form_element =& _rules_forms_get_element($form, $element_id);
$lines = explode("\r\n", trim($value));
$processed_options = array();
foreach ($lines as $line) {
$line = trim($line);
if (preg_match('/^([^|]+)\\|(.*)$/', $line, $matches)) {
$processed_options[$matches[1]] = $matches[2];
}
}
if (isset($form_element['#type'])) {
$form_element['#options'] = $processed_options;
}
}