コード例 #1
0
ファイル: DisplayTest.php プロジェクト: ddrozdik/dmaps
 /**
  * {@inheritdoc}
  */
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     switch ($form_state->get('section')) {
         case 'test_option':
             $form['#title'] .= $this->t('Test option');
             $form['test_option'] = array('#title' => $this->t('Test option'), '#type' => 'textfield', '#description' => $this->t('This is a textfield for test_option.'), '#default_value' => $this->getOption('test_option'));
             break;
     }
 }
コード例 #2
0
ファイル: Attachment.php プロジェクト: anatalsceo/en-classe
 /**
  * Provide the default form for setting options.
  */
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     // It is very important to call the parent function here:
     parent::buildOptionsForm($form, $form_state);
     switch ($form_state['section']) {
         case 'inherit_arguments':
             $form['#title'] .= t('Inherit contextual filters');
             $form['inherit_arguments'] = array('#type' => 'checkbox', '#title' => t('Inherit'), '#description' => t('Should this display inherit its contextual filter values from the parent display to which it is attached?'), '#default_value' => $this->getOption('inherit_arguments'));
             break;
         case 'inherit_exposed_filters':
             $form['#title'] .= t('Inherit exposed filters');
             $form['inherit_exposed_filters'] = array('#type' => 'checkbox', '#title' => t('Inherit'), '#description' => t('Should this display inherit its exposed filter values from the parent display to which it is attached?'), '#default_value' => $this->getOption('inherit_exposed_filters'));
             break;
         case 'inherit_pager':
             $form['#title'] .= t('Inherit pager');
             $form['inherit_pager'] = array('#type' => 'checkbox', '#title' => t('Inherit'), '#description' => t('Should this display inherit its paging values from the parent display to which it is attached?'), '#default_value' => $this->getOption('inherit_pager'));
             break;
         case 'render_pager':
             $form['#title'] .= t('Render pager');
             $form['render_pager'] = array('#type' => 'checkbox', '#title' => t('Render'), '#description' => t('Should this display render the pager values? This is only meaningful if inheriting a pager.'), '#default_value' => $this->getOption('render_pager'));
             break;
         case 'attachment_position':
             $form['#title'] .= t('Position');
             $form['attachment_position'] = array('#title' => t('Position'), '#type' => 'radios', '#description' => t('Attach before or after the parent display?'), '#options' => $this->attachmentPositions(), '#default_value' => $this->getOption('attachment_position'));
             break;
         case 'displays':
             $form['#title'] .= t('Attach to');
             $displays = array();
             foreach ($this->view->storage->get('display') as $display_id => $display) {
                 if ($this->view->displayHandlers->has($display_id) && $this->view->displayHandlers->get($display_id)->acceptAttachments()) {
                     $displays[$display_id] = $display['display_title'];
                 }
             }
             $form['displays'] = array('#title' => t('Displays'), '#type' => 'checkboxes', '#description' => t('Select which display or displays this should attach to.'), '#options' => $displays, '#default_value' => $this->getOption('displays'));
             break;
     }
 }
コード例 #3
0
 /**
  * Provide the default form for setting options.
  */
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     switch ($form_state->get('section')) {
         case 'block_description':
             $form['#title'] .= $this->t('Block admin description');
             $form['block_description'] = array('#type' => 'textfield', '#description' => $this->t('This will appear as the name of this block in administer >> structure >> blocks.'), '#default_value' => $this->getOption('block_description'));
             break;
         case 'block_category':
             $form['#title'] .= $this->t('Block category');
             $form['block_category'] = array('#type' => 'textfield', '#autocomplete_route_name' => 'block.category_autocomplete', '#description' => $this->t('The category this block will appear under on the <a href=":href">blocks placement page</a>.', array(':href' => \Drupal::url('block.admin_display'))), '#default_value' => $this->getOption('block_category'));
             break;
         case 'block_hide_empty':
             $form['#title'] .= $this->t('Block empty settings');
             $form['block_hide_empty'] = array('#title' => $this->t('Hide block if no result/empty text'), '#type' => 'checkbox', '#description' => $this->t('Hide the block if there is no result and no empty text and no header/footer which is shown on empty result'), '#default_value' => $this->getOption('block_hide_empty'));
             break;
         case 'exposed_form_options':
             $this->view->initHandlers();
             if (!$this->usesExposed() && parent::usesExposed()) {
                 $form['exposed_form_options']['warning'] = array('#weight' => -10, '#markup' => '<div class="messages messages--warning">' . $this->t('Exposed filters in block displays require "Use AJAX" to be set to work correctly.') . '</div>');
             }
             break;
         case 'allow':
             $form['#title'] .= $this->t('Allow settings in the block configuration');
             $options = array('items_per_page' => $this->t('Items per page'));
             $allow = array_filter($this->getOption('allow'));
             $form['allow'] = array('#type' => 'checkboxes', '#default_value' => $allow, '#options' => $options);
             break;
     }
 }
コード例 #4
0
 /**
  * Overrides \Drupal\views\Plugin\views\display\DisplayPluginBase::buildOptionsForm().
  */
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     switch ($form_state->get('section')) {
         case 'path':
             $form['#title'] .= $this->t('The menu path or URL of this view');
             $form['path'] = array('#type' => 'textfield', '#title' => $this->t('Path'), '#description' => $this->t('This view will be displayed by visiting this path on your site. You may use "%" in your URL to represent values that will be used for contextual filters: For example, "node/%/feed". If needed you can even specify named route parameters like taxonomy/term/%taxonomy_term'), '#default_value' => $this->getOption('path'), '#field_prefix' => '<span dir="ltr">' . $this->url('<none>', [], ['absolute' => TRUE]), '#field_suffix' => '</span>&lrm;', '#attributes' => array('dir' => LanguageInterface::DIRECTION_LTR), '#maxlength' => 254);
             break;
     }
 }