You are here

abstract class Notifications_Field_Select in Notifications 7

Field with selectable values

Hierarchy

Expanded class hierarchy of Notifications_Field_Select

File

./notifications.field.inc, line 446
Drupal Notifications Framework - Default class file

View source
abstract class Notifications_Field_Select extends Notifications_Field {
  public abstract function select_options();

  /**
   * Build a form element to edit this field
   */
  function element_edit($element = array()) {
    $element += array(
      '#required' => TRUE,
      '#title' => $this
        ->get_title(),
    );
    $options = $this
      ->select_options();

    // If not required or not current value, add an empty value at the beginning
    if (empty($element['#required'])) {
      $options = array(
        '' => '',
      ) + $options;
    }
    $element += array(
      '#type' => 'select',
      '#options' => $options,
      '#default_value' => $this
        ->get_value(),
    );
    return $element;
  }

  /**
   * Translate name into options
   */
  function get_name() {
    if (($value = $this
      ->get_value()) && ($options = $this
      ->select_options()) && isset($options[$value])) {
      return $options[$value];
    }
  }

  /**
   * Check valid value
   */
  function valid_value($value = NULL) {
    return ($options = $this
      ->select_options()) && isset($options[$value]);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Notifications_Field::$data_type protected property 1
Notifications_Field::$name public property
Notifications_Field::$object protected property
Notifications_Field::$object_type public property 6
Notifications_Field::$position public property
Notifications_Field::$sid public property
Notifications_Field::$subscription protected property
Notifications_Field::$type public property 6
Notifications_Field::$value public property
Notifications_Field::build public static function Quick build
Notifications_Field::build_from_value public static function Build a field object from submitted values
Notifications_Field::build_object public static function Build from db object
Notifications_Field::build_type public static function Build field instance
Notifications_Field::check_value function Check if the field has a valid value or the parameter is a valid value
Notifications_Field::drupal_object function Get related Drupal object
Notifications_Field::element_info function Build a form element to display this field
Notifications_Field::format function Format title and value
Notifications_Field::format_value function Format value
Notifications_Field::get_description abstract public function Get description 6
Notifications_Field::get_link function Get link if this field is linked to an object
Notifications_Field::get_object function Get related Notifications object 1
Notifications_Field::get_path function Get system path 3
Notifications_Field::get_property protected function Get field type property
Notifications_Field::get_query_condition function Get query condition for current value
Notifications_Field::get_title public function Get title for field 6
Notifications_Field::get_value function Get field value
Notifications_Field::get_value_condition function Get query condition for a given value
Notifications_Field::index function Get unique index for this field
Notifications_Field::load_multiple public static function Load multiple fields
Notifications_Field::object_value function Get value/s from object 3
Notifications_Field::parse_value function Parse value from form submission 1
Notifications_Field::save function Save to db
Notifications_Field::set_subscription function Set subscription
Notifications_Field::set_value function Set value for this field, update related properties
Notifications_Field::type_info public static function Get field type information
Notifications_Field::user_access function Check user access
Notifications_Field::validate_value static function Check if the value is valid for this field has a valid value
Notifications_Field::__construct public function Constructor
Notifications_Field::__sleep public function PHP Magic. Regurn object properties to be serialized
Notifications_Field_Select::element_edit function Build a form element to edit this field Overrides Notifications_Field::element_edit
Notifications_Field_Select::get_name function Translate name into options Overrides Notifications_Field::get_name
Notifications_Field_Select::select_options abstract public function 2
Notifications_Field_Select::valid_value function Check valid value Overrides Notifications_Field::valid_value