function rules_ui_add_event

Add a new event.

2 calls to rules_ui_add_event()
rules_admin_add_reaction_rule in rules_admin/rules_admin.inc
Add reaction rules form.
rules_ui_add_event_page in ui/ui.forms.inc
Form builder for the "add event" page.

File

ui/ui.forms.inc, line 458

Code

function rules_ui_add_event($form, &$form_state, RulesReactionRule $rules_config, $base_path) {
    $form_state += array(
        'rules_config' => $rules_config,
    );
    $events = array_diff_key(rules_fetch_data('event_info'), array_flip($rules_config->events()));
    $form['help'] = array(
        '#markup' => t('Select the event to add. However note that all added events need to provide all variables that should be available to your rule.'),
    );
    $form['event'] = array(
        '#type' => 'select',
        '#title' => t('React on event'),
        '#options' => RulesPluginUI::getOptions('event', $events),
        '#description' => t('Whenever the event occurs, rule evaluation is triggered.'),
        '#ajax' => rules_ui_form_default_ajax(),
        '#required' => TRUE,
    );
    if (!empty($form_state['values']['event'])) {
        $handler = rules_get_event_handler($form_state['values']['event']);
        $form['event_settings'] = $handler->buildForm($form_state);
    }
    else {
        $form['event_settings'] = array();
    }
    $form['submit'] = array(
        '#type' => 'submit',
        '#value' => t('Add'),
    );
    $form_state['redirect'] = RulesPluginUI::path($rules_config->name);
    return $form;
}