示例#1
0
  /**
   * {@inheritdoc}
   */
  protected function valueForm(&$form, FormStateInterface $form_state) {
    parent::valueForm($form, $form_state);

    // If we are using the date popup widget, overwrite the settings of the form
    // according to what date_popup expects.
    if ($this->options['widget_type'] == 'date_popup' && \Drupal::moduleHandler()->moduleExists('date_popup')) {
      $form['value']['#type'] = 'date_popup';
      $form['value']['#date_format'] = 'm/d/Y';
      unset($form['value']['#description']);
    }
    elseif (!$form_state->get('exposed')) {
      $form['value']['#description'] = $this->t('A date in any format understood by <a href="@doc-link">PHP</a>. For example, "@date1" or "@date2".', array(
        '@doc-link' => 'http://php.net/manual/en/function.strtotime.php',
        '@date1' => format_date(REQUEST_TIME, 'custom', 'Y-m-d H:i:s'),
        '@date2' => 'now + 1 day',
      ));
    }
  }
示例#2
0
 /**
  * {@inheritdoc}
  */
 public function adminSummary() {
   if (!is_array($this->value)) {
     $this->value = $this->value ? array($this->value) : array();
   }
   $value = $this->value;
   $this->value = empty($value) ? '' : $this->idsToString($value);
   $ret = parent::adminSummary();
   $this->value = $value;
   return $ret;
 }
示例#3
0
 /**
  * {@inheritdoc}
  */
 public function buildExposedForm(&$form, FormStateInterface $form_state) {
   parent::buildExposedForm($form, $form_state);
   $form['expose']['reduce'] = array(
     '#type' => 'checkbox',
     '#title' => $this->t('Limit list to selected items'),
     '#description' => $this->t('If checked, the only items presented to the user will be the ones selected here.'),
     '#default_value' => !empty($this->options['expose']['reduce']),
   );
 }