Esempio n. 1
0
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     $vocabularies = $this->vocabularyStorage->loadMultiple();
     $options = array();
     foreach ($vocabularies as $voc) {
         $options[$voc->id()] = $voc->label();
     }
     $form['vids'] = array('#type' => 'checkboxes', '#title' => $this->t('Vocabularies'), '#options' => $options, '#default_value' => $this->options['vids'], '#description' => $this->t('Choose which vocabularies you wish to relate. Remember that every term found will create a new record, so this relationship is best used on just one vocabulary that has only one term per node.'));
     parent::buildOptionsForm($form, $form_state);
 }
Esempio n. 2
0
 public function buildExtraOptionsForm(&$form, FormStateInterface $form_state)
 {
     $vocabularies = $this->vocabularyStorage->loadMultiple();
     $options = array();
     foreach ($vocabularies as $voc) {
         $options[$voc->id()] = $voc->label();
     }
     if ($this->options['limit']) {
         // We only do this when the form is displayed.
         if (empty($this->options['vid'])) {
             $first_vocabulary = reset($vocabularies);
             $this->options['vid'] = $first_vocabulary->id();
         }
         if (empty($this->definition['vocabulary'])) {
             $form['vid'] = array('#type' => 'radios', '#title' => $this->t('Vocabulary'), '#options' => $options, '#description' => $this->t('Select which vocabulary to show terms for in the regular options.'), '#default_value' => $this->options['vid']);
         }
     }
     $form['type'] = array('#type' => 'radios', '#title' => $this->t('Selection type'), '#options' => array('select' => $this->t('Dropdown'), 'textfield' => $this->t('Autocomplete')), '#default_value' => $this->options['type']);
     $form['hierarchy'] = array('#type' => 'checkbox', '#title' => $this->t('Show hierarchy in dropdown'), '#default_value' => !empty($this->options['hierarchy']), '#states' => array('visible' => array(':input[name="options[type]"]' => array('value' => 'select'))));
 }