You are here

function views_handler_filter_string_compare::value_form in Amazon Product Advertisement API 7

Same name and namespace in other branches
  1. 6 includes/views_handler_filter_string_compare.inc \views_handler_filter_string_compare::value_form()
  2. 7.2 includes/views_handler_filter_string_compare.inc \views_handler_filter_string_compare::value_form()

Provide a simple textfield for equality

Overrides views_handler_filter::value_form

File

includes/views_handler_filter_string_compare.inc, line 157

Class

views_handler_filter_string_compare
Basic textfield filter to handle string filtering commands including equality, like, not like, etc.

Code

function value_form(&$form, &$form_state) {

  // We have to make some choices when creating this as an exposed
  // filter form. For example, if the operator is locked and thus
  // not rendered, we can't render dependencies; instead we only
  // render the form items we need.
  $which = 'all';
  if (!empty($form['operator'])) {
    $source = $form['operator']['#type'] == 'radios' ? 'radio:options[operator]' : 'edit-options-operator';
  }
  if (!empty($form_state['exposed'])) {
    $identifier = $this->options['expose']['identifier'];
    if (empty($this->options['expose']['use_operator']) || empty($this->options['expose']['operator'])) {

      // exposed and locked.
      $which = in_array($this->operator, $this
        ->operator_values(1)) ? 'value' : 'none';
    }
    else {
      $source = 'edit-' . form_clean_id($this->options['expose']['operator']);
    }
  }
  if ($which == 'all' || $which == 'value') {
    $form['value'] = array(
      '#type' => 'textfield',
      '#title' => t('Value'),
      '#size' => 30,
      '#default_value' => $this->value,
    );
    if (!empty($form_state['exposed']) && !isset($form_state['input'][$identifier])) {
      $form_state['input'][$identifier] = $this->value;
    }
    if ($which == 'all') {
      $form['value'] += array(
        '#process' => array(
          'ctools_dependent_process',
        ),
        '#dependency' => array(
          $source => $this
            ->operator_values(1),
        ),
      );
    }
  }
  if (!isset($form['value'])) {

    // Ensure there is something in the 'value'.
    $form['value'] = array(
      '#type' => 'value',
      '#value' => NULL,
    );
  }
}