function rules_ui_add_element_submit in Rules 7.2
Add element submit callback.
Used for "abstract plugins" to create the initial element object with the given implementation name and rebuild the form.
File
- ui/
ui.forms.inc, line 316 - Rules User Interface forms.
Code
function rules_ui_add_element_submit($form, &$form_state) {
$element = rules_plugin_factory($form_state['plugin'], $form_state['values']['element_name']);
// Always add the new element at the bottom, thus set an appropriate weight.
$iterator = $form_state['parent_element']
->getIterator();
if ($sibling = end($iterator)) {
$element->weight = $sibling->weight + 1;
}
// Clear the element settings so they won't be processed on serialization as
// there is nothing to be processed yet.
$element->settings = array();
$element
->setParent($form_state['parent_element']);
$form_state['rules_element'] = $element;
$form_state['rebuild'] = TRUE;
}