public function RulesContainerPluginUI::form in Rules 7.2
Generates a table for editing the contained elements.
Overrides RulesPluginUI::form
2 calls to RulesContainerPluginUI::form()
- RulesActionContainerUI::form in ui/
ui.core.inc - Implements RulesPluginUIInterface::form().
- RulesConditionContainerUI::form in ui/
ui.core.inc - Implements RulesPluginUIInterface::form().
2 methods override RulesContainerPluginUI::form()
- RulesActionContainerUI::form in ui/
ui.core.inc - Implements RulesPluginUIInterface::form().
- RulesConditionContainerUI::form in ui/
ui.core.inc - Implements RulesPluginUIInterface::form().
File
- ui/
ui.core.inc, line 1012 - Contains core Rules UI functions.
Class
- RulesContainerPluginUI
- UI for Rules Container.
Code
public function form(&$form, &$form_state, $options = array(), $iterator = NULL) {
parent::form($form, $form_state, $options);
$form['elements'] = array(
// Hide during creation or for embedded elements.
'#access' => empty($options['init']) && $this->element
->isRoot(),
'#tree' => TRUE,
'#theme' => 'rules_elements',
'#empty' => t('None'),
'#caption' => t('Elements'),
);
$form['elements']['#attributes']['class'][] = 'rules-container-plugin';
// Recurse over all element children or use the provided iterator.
$iterator = isset($iterator) ? $iterator : $this->element
->elements();
$root_depth = $this->element
->depth();
foreach ($iterator as $key => $child) {
$id = $child
->elementId();
// Do not render rules as container element when displayed in a rule set.
$is_container = $child instanceof RulesContainerPlugin && !$child instanceof Rule;
$form['elements'][$id] = array(
'#depth' => $child
->depth() - $root_depth - 1,
'#container' => $is_container,
);
$form['elements'][$id]['label'] = $child
->buildContent();
$form['elements'][$id]['weight'] = array(
'#type' => 'weight',
'#default_value' => $child->weight,
'#delta' => 50,
);
$form['elements'][$id]['parent_id'] = array(
'#type' => 'hidden',
// If another iterator is passed in, the child parent may not equal
// the current element. Thus ask the child for its parent.
'#default_value' => $child
->parentElement()
->elementId(),
);
$form['elements'][$id]['element_id'] = array(
'#type' => 'hidden',
'#default_value' => $id,
);
$form['elements'][$id]['operations'] = $child
->operations();
}
// Alter the submit button label.
if (!empty($options['button']) && !empty($options['init'])) {
$form['submit']['#value'] = t('Continue');
}
elseif (!empty($options['button']) && $this->element
->isRoot()) {
$form['submit']['#value'] = t('Save changes');
}
}