function views_rules_add_view_loop in Views Rules 7
Provides a variant of rules_ui_add_element() to present a view display selector for creating a view loop.
1 string reference to 'views_rules_add_view_loop'
- _views_rules_rules_ui_menu_alter in rules/
views_rules.rules_admin.inc - Adds extra Rules controller callback.
File
- rules/
views_rules.rules_admin.inc, line 33 - Extensions to Rules UI.
Code
function views_rules_add_view_loop($form, &$form_state, $rules_config, $plugin_name, RulesContainerPlugin $parent, $base_path) {
$cache = rules_get_cache();
if (!isset($cache['plugin_info'][$plugin_name]['class'])) {
drupal_not_found();
exit;
}
// Build condition form.
RulesPluginUI::$basePath = $base_path;
if (!isset($form_state['rules_element'])) {
RulesPluginUI::formDefaults($form, $form_state);
$form_state += array(
'parent_element' => $parent,
'plugin' => $plugin_name,
);
// Add view selector.
$form['views_rules_display'] = array(
'#type' => 'select',
'#title' => t('Views iterator display'),
'#options' => views_rules_list_iterators(),
'#description' => t('Select the view display to use for looping. To add a display to the list, add a "Rules" display to a view.'),
'#required' => TRUE,
'#ajax' => rules_ui_form_default_ajax() + array(
'trigger_as' => array(
'name' => 'continue',
),
),
);
$form['continue'] = array(
'#type' => 'submit',
'#name' => 'continue',
'#value' => t('Continue'),
'#ajax' => rules_ui_form_default_ajax(),
);
}
// Build element form.
if (isset($form_state['rules_element'])) {
$form_state['rules_element']
->form($form, $form_state, array(
'button' => TRUE,
'init' => TRUE,
));
$form['#validate'][] = 'rules_ui_edit_element_validate';
$form['#submit'][] = 'rules_ui_edit_element_submit';
}
else {
$form['#submit'][] = 'views_rules_add_view_loop_submit';
}
return $form;
}