You are here

class RulesDataUIEventStateReference in Booking and Availability Management Tools for Drupal 7

Defines a bat_event_state_reference input form for Rules.

Hierarchy

Expanded class hierarchy of RulesDataUIEventStateReference

1 string reference to 'RulesDataUIEventStateReference'
bat_event_rules_data_info in modules/bat_event/bat_event.rules.inc
Implements hook_rules_data_info().

File

modules/bat_event/bat_event.rules.inc, line 24

View source
class RulesDataUIEventStateReference extends RulesDataUI implements RulesDataDirectInputFormInterface {

  /**
   * {@inheritdoc}
   */
  public static function getDefaultMode() {
    return 'input';
  }

  /**
   * {@inheritdoc}
   */
  public static function inputForm($name, $info, $settings, RulesPlugin $element) {
    $settings += array(
      $name => isset($info['default value']) ? $info['default value'] : array(
        'state' => '',
      ),
    );
    $value = $settings[$name];
    $options = array();
    foreach (bat_event_get_states() as $state) {
      $options[$state['machine_name']] = $state['label'] . ' (' . $state['id'] . ')';
    }
    $form[$name]['state'] = array(
      '#type' => 'select',
      '#options' => $options,
      '#default_value' => isset($value['state']) ? $value['state'] : '',
      '#required' => TRUE,
    );
    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public static function render($value) {
    return array(
      'content' => array(
        '#markup' => $value['state'],
      ),
    );
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RulesDataUI::getTypeInfo public static function Returns the data type and parameter information for the given arguments.
RulesDataUI::renderOptionsLabel public static function Renders the value with a label if an options list is available.
RulesDataUI::selectionForm public static function Provides the selection form for a parameter.
RulesDataUIEventStateReference::getDefaultMode public static function Specifies the default input mode per data type. Overrides RulesDataUI::getDefaultMode
RulesDataUIEventStateReference::inputForm public static function Constructs the direct input form. Overrides RulesDataDirectInputFormInterface::inputForm
RulesDataUIEventStateReference::render public static function Render the configured value. Overrides RulesDataDirectInputFormInterface::render