function RulesReactionRuleUI::form

Overrides RulesRuleUI::form

File

ui/ui.plugins.inc, line 94

Class

RulesReactionRuleUI
Reaction rule specific UI.

Code

public function form(&$form, &$form_state, $options = array(), $iterator = NULL) {
    $form['events'] = array(
        '#type' => 'container',
        '#weight' => -10,
        '#access' => empty($options['init']),
    );
    $form['events']['table'] = array(
        '#theme' => 'table',
        '#caption' => 'Events',
        '#header' => array(
            t('Event'),
            t('Operations'),
        ),
        '#empty' => t('None'),
    );
    $form['events']['table']['#attributes']['class'][] = 'rules-elements-table';
    foreach ($this->rule
        ->events() as $event_name) {
        $event_handler = rules_get_event_handler($event_name, $this->rule
            ->getEventSettings($event_name));
        $event_operations = array(
            '#theme' => 'links__rules',
            '#attributes' => array(
                'class' => array(
                    'rules-operations',
                    'action-links',
                    'rules_rule_event',
                ),
            ),
            '#links' => array(
                'delete_event' => array(
                    'title' => t('delete'),
                    'href' => RulesPluginUI::path($this->rule->name, 'delete/event/' . $event_name),
                    'query' => drupal_get_destination(),
                ),
            ),
        );
        $form['events']['table']['#rows'][$event_name] = array(
            'data' => array(
                $event_handler->summary(),
                array(
                    'data' => $event_operations,
                ),
            ),
        );
    }
    // Add the "add event" row.
    $cell['colspan'] = 3;
    $cell['data']['#theme'] = 'links__rules';
    $cell['data']['#attributes']['class'][] = 'rules-operations-add';
    $cell['data']['#attributes']['class'][] = 'action-links';
    $cell['data']['#links']['add_event'] = array(
        'title' => t('Add event'),
        'href' => RulesPluginUI::path($this->rule->name, 'add/event'),
        'query' => drupal_get_destination(),
    );
    $form['events']['table']['#rows'][] = array(
        'data' => array(
            $cell,
        ),
        'class' => array(
            'rules-elements-add',
        ),
    );
    parent::form($form, $form_state, $options);
    unset($form['label']);
}