Exemple #1
0
  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state, $field_key = '') {
    $form = parent::buildForm($form, $form_state, $field_key);
    $field = $this->field;

    $form['content'] = array(
      '#type' => 'text_format',
      '#title' => t('Field content'),
      '#default_value' => isset($field['properties']['content']['value']) ? $field['properties']['content']['value'] : '',
      '#format' => isset($field['properties']['content']['format']) ? $field['properties']['content']['format'] : 'plain_text',
      '#base_type' => 'textarea',
      '#required' => TRUE,
    );

    // Token support.
    if (\Drupal::moduleHandler()->moduleExists('token')) {
      $form['tokens'] = array(
        '#title' => t('Tokens'),
        '#type' => 'container',
        '#states' => array(
          'invisible' => array(
            'input[name="use_token"]' => array('checked' => FALSE),
          ),
        ),
      );
      $form['tokens']['help'] = array(
        '#theme' => 'token_tree',
        '#token_types' => 'all',
        '#global_types' => FALSE,
        '#dialog' => TRUE,
      );
    }

    return $form;
  }
Exemple #2
0
  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state, $field_key = '') {
    $form = parent::buildForm($form, $form_state, $field_key);
    $field = $this->field;

    $manager = \Drupal::service('plugin.manager.ds');

    $fields = array();
    foreach ($manager->getDefinitions() as $plugin_id => $plugin_definition) {
      $entity_label = '';
      if (isset($plugin_definition['entity_type'])) {
        $entity_label .= ucfirst(str_replace('_', ' ', $plugin_definition['entity_type'])) . ' - ';
      }
      $fields[$plugin_id] = $entity_label . $plugin_definition['title'];
    }
    asort($fields);

    $form['ds_field_identity']['ds_plugin'] = array(
      '#type' => 'select',
      '#options' => $fields,
      '#title' => t('Fields'),
      '#required' => TRUE,
      '#default_value' => isset($field['properties']['ds_plugin']) ? $field['properties']['ds_plugin'] : '',
    );

    return $form;
  }
Exemple #3
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, $field_key = '')
 {
     $form = parent::buildForm($form, $form_state, $field_key);
     $field = $this->field;
     $manager = \Drupal::service('plugin.manager.block');
     $blocks = array();
     foreach ($manager->getDefinitions() as $plugin_id => $plugin_definition) {
         $blocks[$plugin_id] = $plugin_definition['admin_label'];
     }
     asort($blocks);
     $form['block_identity']['block'] = array('#type' => 'select', '#options' => $blocks, '#title' => t('Block'), '#required' => TRUE, '#default_value' => isset($field['properties']['block']) ? $field['properties']['block'] : '');
     $form['use_block_title'] = array('#type' => 'checkbox', '#title' => $this->t('Use block title as the field label'), '#default_value' => isset($field['properties']['use_block_title']) ? $field['properties']['use_block_title'] : FALSE, '#weight' => 90);
     return $form;
 }