function rules_forms_options_set in Rules Forms Support 7.2
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
RulesFormsAttributeWrapper $wrapper: The wrapped form element attribute.
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_options_set'
- _rules_forms_attribute_info in includes/
rules_forms.info.inc - Retrieve a list of Form API properties with supported attributes information.
File
- includes/
rules_forms.eval.inc, line 249 - Evaluation functions for Rules Forms module.
Code
function rules_forms_options_set(EntityMetadataWrapper $wrapper, $value) {
$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];
}
}
$wrapper
->set($processed_options);
}