function rules_ui_element_variable_form_validate
FAPI callback to validate the form for editing variable info.
See also
RulesPluginUI::getVariableForm()
1 string reference to 'rules_ui_element_variable_form_validate'
- RulesPluginUI::settingsForm in ui/
ui.core.inc - Adds the configuration settings form (label, tags, description, ...).
File
-
ui/
ui.forms.inc, line 925
Code
function rules_ui_element_variable_form_validate($elements, &$form_state) {
$names = array();
foreach (element_children($elements['items']) as $item_key) {
$element =& $elements['items'][$item_key];
if ($element['name']['#value'] || $element['type']['#value'] || $element['label']['#value']) {
foreach (array(
'name' => t('Machine name'),
'label' => t('Label'),
'type' => t('Data type'),
) as $key => $title) {
if (!$element[$key]['#value']) {
form_error($element[$key], t('!name field is required.', array(
'!name' => $title,
)));
}
}
if (isset($names[$element['name']['#value']])) {
form_error($element['name'], t('The machine-readable name %name is already taken.', array(
'%name' => $element['name']['#value'],
)));
}
$names[$element['name']['#value']] = TRUE;
}
}
}