Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $user = $this->currentUser();
     $message = $this->entity;
     $form = parent::form($form, $form_state, $message);
     $form['#attributes']['class'][] = 'contact-form';
     if (!empty($message->preview)) {
         $form['preview'] = array('#theme_wrappers' => array('container__preview'), '#attributes' => array('class' => array('preview')));
         $form['preview']['message'] = $this->entityManager->getViewBuilder('contact_message')->view($message, 'full');
     }
     $form['name'] = array('#type' => 'textfield', '#title' => $this->t('Your name'), '#maxlength' => 255, '#required' => TRUE);
     $form['mail'] = array('#type' => 'email', '#title' => $this->t('Your email address'), '#required' => TRUE);
     if ($user->isAnonymous()) {
         $form['#attached']['library'][] = 'core/drupal.form';
         $form['#attributes']['data-user-info-from-browser'] = TRUE;
     } else {
         $form['name']['#type'] = 'item';
         $form['name']['#value'] = $user->getDisplayName();
         $form['name']['#required'] = FALSE;
         $form['name']['#plain_text'] = $user->getDisplayName();
         $form['mail']['#type'] = 'item';
         $form['mail']['#value'] = $user->getEmail();
         $form['mail']['#required'] = FALSE;
         $form['mail']['#plain_text'] = $user->getEmail();
     }
     // The user contact form has a preset recipient.
     if ($message->isPersonal()) {
         $form['recipient'] = array('#type' => 'item', '#title' => $this->t('To'), '#value' => $message->getPersonalRecipient()->id(), 'name' => array('#theme' => 'username', '#account' => $message->getPersonalRecipient()));
     }
     $form['copy'] = array('#type' => 'checkbox', '#title' => $this->t('Send yourself a copy'), '#access' => $user->isAuthenticated());
     return $form;
 }
  public function form(array $form, FormStateInterface $form_state) {
    $form = parent::form($form, $form_state);

    $form['token_help'] = $this->adminFormHelper->getAdminTokenForm();

    return $form;
  }
Beispiel #3
0
 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $form = parent::form($form, $form_state);
     $form['path'] = array('#type' => 'textfield', '#title' => t('Path'), '#size' => 40, '#maxlength' => 255, '#field_prefix' => $this->url('<front>', array(), array('absolute' => TRUE)), '#default_value' => $this->entity->path->value);
     $form['langcode'] = array('#title' => t('Language'), '#type' => 'language_select', '#default_value' => $this->entity->getUntranslated()->language()->id, '#languages' => LanguageInterface::STATE_ALL);
     return $form;
 }
Beispiel #4
0
  /**
   * {@inheritdoc}
   */
  public function form(array $form, FormStateInterface $form_state) {
    $form = parent::form($form, $form_state);

    $form['#title'] = $this->t('Edit subqueue %label', ['%label' => $this->entity->label()]);

    // Since the form has ajax buttons, the $wrapper_id will change each time
    // one of those buttons is clicked. Therefore the whole form has to be
    // replaced, otherwise the buttons will have the old $wrapper_id and will
    // only work on the first click.
    if ($form_state->has('subqueue_form_wrapper_id')) {
      $wrapper_id = $form_state->get('subqueue_form_wrapper_id');
    }
    else {
      $wrapper_id = Html::getUniqueId($this->getFormId() . '-wrapper');
    }

    $form_state->set('subqueue_form_wrapper_id', $wrapper_id);
    $form['#prefix'] = '<div id="' . $wrapper_id . '">';
    $form['#suffix'] = '</div>';

    // @todo Consider creating a 'Machine name' field widget.
    $form['name'] = [
      '#type' => 'machine_name',
      '#default_value' => $this->entity->id(),
      '#machine_name' => array(
        'exists' => '\Drupal\entityqueue\Entity\EntitySubqueue::load',
        'source' => ['title', 'widget', 0, 'value'],
      ),
      '#disabled' => !$this->entity->isNew(),
      '#weight' => -5,
      '#access' => !$this->entity->getQueue()->getHandlerPlugin()->hasAutomatedSubqueues(),
    ];

    return $form;
  }
 /**
  * Overrides Drupal\Core\Entity\EntityForm::form().
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $form = parent::form($form, $form_state);
     $this->getSubscriptionWidget($form_state)->setAvailableNewsletterIds(array_keys(simplenews_newsletter_get_visible()));
     /* @var \Drupal\simplenews\SubscriberInterface $subscriber */
     $subscriber = $this->entity;
     $form['#title'] = $this->t('Edit subscriber @mail', array('@mail' => $subscriber->getMail()));
     $form['activated'] = array('#title' => t('Status'), '#type' => 'fieldset', '#description' => t('Active or inactive account.'), '#weight' => 15);
     $form['activated']['status'] = array('#type' => 'checkbox', '#title' => t('Active'), '#default_value' => $subscriber->getStatus());
     $language_manager = \Drupal::languageManager();
     if ($language_manager->isMultilingual()) {
         $languages = $language_manager->getLanguages();
         foreach ($languages as $langcode => $language) {
             $language_options[$langcode] = $language->getName();
         }
         $form['language'] = array('#type' => 'fieldset', '#title' => t('Preferred language'), '#description' => t('The e-mails will be localized in language chosen. Real users have their preference in account settings.'), '#disabled' => FALSE);
         if ($subscriber->getUserId()) {
             // Fallback if user has not defined a language.
             $form['language']['langcode'] = array('#type' => 'item', '#title' => t('User language'), '#markup' => $subscriber->language()->getName());
         } else {
             $form['language']['langcode'] = array('#type' => 'select', '#default_value' => $subscriber->language()->getId(), '#options' => $language_options, '#required' => TRUE);
         }
     }
     return $form;
 }
 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $payment = $this->getEntity();
     $form['line_items'] = ['#payment_line_items' => $payment, '#type' => 'payment_line_items_display'];
     $form['payment_method'] = $this->getPluginSelector($form_state)->buildSelectorForm([], $form_state);
     return parent::form($form, $form_state);
 }
 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $entity = $this->entity;
     $form = parent::form($form, $form_state);
     $form['#tree'] = TRUE;
     $form['#theme'] = ['conference_sessions_entity_form'];
     $form['#attached']['library'][] = 'conference_sessions/entity_form';
     $form['meta'] = ['#attributes' => ['class' => ['entity-meta__header']], '#type' => 'container', '#group' => 'advanced', '#weight' => -100, 'published' => ['#type' => 'html_tag', '#tag' => 'h3', '#value' => $entity->isPublished() ? $this->t('Published') : $this->t('Not published'), '#access' => !$entity->isNew(), '#attributes' => ['class' => 'entity-meta__title']], 'changed' => ['#type' => 'item', '#wrapper_attributes' => ['class' => ['entity-meta__last-saved', 'container-inline']], '#markup' => '<h4 class="label inline">' . $this->t('Last saved') . '</h4> ' . $entity->getChangedTime()]];
     if ($this->entity instanceof EntityOwnerInterface) {
         $form['meta']['author'] = ['#type' => 'item', '#wrapper_attributes' => ['class' => ['author', 'container-inline']], '#markup' => '<h4 class="label inline">' . $this->t('Author') . '</h4> ' . $entity->getOwner()->getDisplayName()];
     }
     $form['advanced'] = ['#type' => 'container', '#attributes' => ['class' => ['entity-meta']], '#weight' => 99];
     $form['visibility_settings'] = ['#type' => 'details', '#title' => t('Visibility settings'), '#open' => TRUE, '#group' => 'advanced', '#access' => !empty($form['stores']['#access']), '#attributes' => ['class' => ['product-visibility-settings']], '#weight' => 30];
     $form['path_settings'] = ['#type' => 'details', '#title' => t('URL path settings'), '#open' => !empty($form['path']['widget'][0]['alias']['#value']), '#group' => 'advanced', '#access' => !empty($form['path']['#access']) && $entity->get('path')->access('edit'), '#attributes' => ['class' => ['path-form']], '#attached' => ['library' => ['path/drupal.path']], '#weight' => 60];
     $form['author'] = ['#type' => 'details', '#title' => t('Authoring information'), '#group' => 'advanced', '#attributes' => ['class' => ['product-form-author']], '#attached' => ['library' => ['commerce_product/drupal.commerce_product']], '#weight' => 90, '#optional' => TRUE];
     if (isset($form['uid'])) {
         $form['uid']['#group'] = 'author';
     }
     if (isset($form['created'])) {
         $form['created']['#group'] = 'author';
     }
     if (isset($form['path'])) {
         $form['path']['#group'] = 'path_settings';
     }
     return $form;
 }
Beispiel #8
0
 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     /* @var \Drupal\commerce_product\Entity\Product $product */
     $product = $this->entity;
     $form = parent::form($form, $form_state);
     $form['#tree'] = TRUE;
     $form['#theme'] = ['product_form'];
     $form['#attached']['library'][] = 'commerce_product/form';
     $form['#entity_builders']['update_status'] = [$this, 'updateStatus'];
     // Changed must be sent to the client, for later overwrite error checking.
     $form['changed'] = ['#type' => 'hidden', '#default_value' => $product->getChangedTime()];
     $last_saved = t('Not saved yet');
     if (!$product->isNew()) {
         $last_saved = $this->dateFormatter->format($product->getChangedTime(), 'short');
     }
     $form['meta'] = ['#attributes' => ['class' => ['entity-meta__header']], '#type' => 'container', '#group' => 'advanced', '#weight' => -100, 'published' => ['#type' => 'html_tag', '#tag' => 'h3', '#value' => $product->isPublished() ? $this->t('Published') : $this->t('Not published'), '#access' => !$product->isNew(), '#attributes' => ['class' => 'entity-meta__title']], 'changed' => ['#type' => 'item', '#wrapper_attributes' => ['class' => ['entity-meta__last-saved', 'container-inline']], '#markup' => '<h4 class="label inline">' . $this->t('Last saved') . '</h4> ' . $last_saved], 'author' => ['#type' => 'item', '#wrapper_attributes' => ['class' => ['author', 'container-inline']], '#markup' => '<h4 class="label inline">' . $this->t('Author') . '</h4> ' . $product->getOwner()->getDisplayName()]];
     $form['advanced'] = ['#type' => 'container', '#attributes' => ['class' => ['entity-meta']], '#weight' => 99];
     $form['path_settings'] = ['#type' => 'details', '#title' => t('URL path settings'), '#open' => !empty($form['path']['widget'][0]['alias']['#value']), '#group' => 'advanced', '#access' => !empty($form['path']['#access']) && $product->get('path')->access('edit'), '#attributes' => ['class' => ['path-form']], '#attached' => ['library' => ['path/drupal.path']], '#weight' => 30];
     $form['author'] = ['#type' => 'details', '#title' => t('Authoring information'), '#group' => 'advanced', '#attributes' => ['class' => ['product-form-author']], '#attached' => ['library' => ['commerce_product/drupal.commerce_product']], '#weight' => 90, '#optional' => TRUE];
     if (isset($form['uid'])) {
         $form['uid']['#group'] = 'author';
     }
     if (isset($form['created'])) {
         $form['created']['#group'] = 'author';
     }
     if (isset($form['path'])) {
         $form['path']['#group'] = 'path_settings';
     }
     return $form;
 }
Beispiel #9
0
 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $media = $this->entity;
     $account = $this->currentUser();
     $form = parent::form($form, $form_state);
     $form['advanced'] = array('#type' => 'vertical_tabs', '#weight' => 99);
     // Add a log field if the "Create new revision" option is checked, or if the
     // current user has the ability to check that option.
     $form['revision_information'] = array('#type' => 'details', '#title' => $this->t('Revision information'), '#open' => $media->isNewRevision(), '#group' => 'advanced', '#attributes' => array('class' => array('media-form-revision-information')), '#weight' => 20, '#access' => $media->isNewRevision() || $account->hasPermission('administer media'));
     $form['revision_information']['revision'] = array('#type' => 'checkbox', '#title' => $this->t('Create new revision'), '#default_value' => $media->isNewRevision(), '#access' => $account->hasPermission('administer media'));
     // Check the revision log checkbox when the log textarea is filled in.
     // This must not happen if "Create new revision" is enabled by default,
     // since the state would auto-disable the checkbox otherwise.
     if (!$media->isNewRevision()) {
         $form['revision_information']['revision']['#states'] = array('checked' => array('textarea[name="revision_log"]' => array('empty' => FALSE)));
     }
     $form['revision_information']['revision_log'] = array('#type' => 'textarea', '#title' => $this->t('Revision log message'), '#rows' => 4, '#default_value' => '', '#description' => $this->t('Briefly describe the changes you have made.'));
     // Node author information for administrators.
     $form['author'] = array('#type' => 'details', '#title' => t('Authoring information'), '#group' => 'advanced', '#attributes' => array('class' => array('node-form-author')), '#attached' => array('library' => array('node/drupal.node')), '#weight' => 90, '#optional' => TRUE);
     if (isset($form['uid'])) {
         $form['uid']['#group'] = 'author';
     }
     if (isset($form['created'])) {
         $form['created']['#group'] = 'author';
     }
     $form['#attached']['library'][] = 'node/form';
     return $form;
 }
 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $field_collection_item = $this->entity;
     if ($this->operation == 'edit') {
         $form['#title'] = $this->t('<em>Edit @type</em>', ['@type' => $field_collection_item->label()]);
     }
     /*
     // Basic item information.
     foreach (array('revision_id', 'id', 'field_name') as $key) {
       $form[$key] = array(
         '#type' => 'value',
         '#value' => $field_collection_item->$key->value,
       );
     }
     
     $language_configuration = module_invoke('language', 'get_default_configuration', 'field_collection_item', $field_collection_item->field_name->value);
     
     // Set the correct default language.
     if ($field_collection_item->isNew() && !empty($language_configuration['langcode'])) {
       $language_default = language($language_configuration['langcode']);
       $field_collection_item->langcode->value = $language_default->langcode;
     }
     
     $form['langcode'] = array(
       '#title' => t('Language'),
       '#type' => 'language_select',
       '#default_value' => $field_collection_item->langcode->value,
       '#languages' => LANGUAGE_ALL,
       '#access' => isset($language_configuration['language_show']) && $language_configuration['language_show'],
     );
     */
     return parent::form($form, $form_state);
 }
Beispiel #11
0
 /**
  * {@inheritdoc}
  */
 public function form(array $form, array &$form_state)
 {
     $user = $this->currentUser();
     $message = $this->entity;
     $form = parent::form($form, $form_state, $message);
     $form['#attributes']['class'][] = 'contact-form';
     if (!empty($message->preview)) {
         $form['preview'] = array('#theme_wrappers' => array('container__preview'), '#attributes' => array('class' => array('preview')));
         $form['preview']['message'] = $this->entityManager->getViewBuilder('contact_message')->view($message, 'full');
     }
     $language_configuration = $this->moduleHandler->invoke('language', 'get_default_configuration', array('contact_message', $message->getCategory()->id()));
     $form['langcode'] = array('#title' => $this->t('Language'), '#type' => 'language_select', '#default_value' => $message->getUntranslated()->language()->id, '#languages' => Language::STATE_ALL, '#access' => isset($language_configuration['language_show']) && $language_configuration['language_show']);
     $form['name'] = array('#type' => 'textfield', '#title' => $this->t('Your name'), '#maxlength' => 255, '#required' => TRUE);
     $form['mail'] = array('#type' => 'email', '#title' => $this->t('Your email address'), '#required' => TRUE);
     if ($user->isAnonymous()) {
         $form['#attached']['library'][] = 'core/jquery.cookie';
         $form['#attributes']['class'][] = 'user-info-from-cookie';
     } else {
         $form['name']['#type'] = 'item';
         $form['name']['#value'] = $user->getUsername();
         $form['name']['#required'] = FALSE;
         $form['name']['#markup'] = String::checkPlain($user->getUsername());
         $form['mail']['#type'] = 'item';
         $form['mail']['#value'] = $user->getEmail();
         $form['mail']['#required'] = FALSE;
         $form['mail']['#markup'] = String::checkPlain($user->getEmail());
     }
     // The user contact form has a preset recipient.
     if ($message->isPersonal()) {
         $form['recipient'] = array('#type' => 'item', '#title' => $this->t('To'), '#value' => $message->getPersonalRecipient()->id(), 'name' => array('#theme' => 'username', '#account' => $message->getPersonalRecipient()));
     }
     $form['copy'] = array('#type' => 'checkbox', '#title' => $this->t('Send yourself a copy.'), '#access' => $user->isAuthenticated());
     return $form;
 }
Beispiel #12
0
  /**
   * {@inheritdoc}
   */
  public function form(array $form, FormStateInterface $form_state) {
    /* @var \Drupal\commerce_order\Entity\Order $order */
    $order = $this->entity;
    $currentUser = $this->currentUser();

    $form['advanced'] = [
      '#type' => 'vertical_tabs',
      '#attributes' => ['class' => ['entity-meta']],
      '#weight' => 99,
    ];
    $form = parent::form($form, $form_state);

    $form['order_status'] = [
      '#type' => 'details',
      '#title' => t('Order status'),
      '#group' => 'advanced',
      '#attributes' => [
        'class' => ['order-form-order-status'],
      ],
      '#attached' => [
        'library' => ['commerce_order/drupal.commerce_order'],
      ],
      '#weight' => 90,
      '#optional' => TRUE,
    ];

    if (isset($form['status'])) {
      $form['status']['#group'] = 'order_status';
    }

    // Order authoring information for administrators.
    $form['author'] = [
      '#type' => 'details',
      '#title' => t('Authoring information'),
      '#group' => 'advanced',
      '#attributes' => [
        'class' => ['order-form-author'],
      ],
      '#attached' => [
        'library' => ['commerce_order/drupal.commerce_order'],
      ],
      '#weight' => 91,
      '#optional' => TRUE,
    ];

    if (isset($form['uid'])) {
      $form['uid']['#group'] = 'author';
    }

    if (isset($form['mail'])) {
      $form['mail']['#group'] = 'author';
    }

    if (isset($form['created'])) {
      $form['created']['#group'] = 'author';
    }

    return $form;
  }
Beispiel #13
0
 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $reservation = $this->entity;
     $season_storage = $this->entityManager->getStorage('season');
     $season = $season_storage->load($reservation->bundle());
     $form['season'] = array('#type' => 'value', '#value' => $season->id());
     return parent::form($form, $form_state);
 }
 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $action = $this->entity;
     if (!$action->isNew()) {
         $form['#title'] = $this->t('Edit @type', array('@type' => $action->getType()));
     }
     $form = $this->plugin->buildConfigurationForm($form, $form_state);
     return parent::form($form, $form_state, $action);
 }
Beispiel #15
0
 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state, GroupInterface $group = NULL)
 {
     $group = $this->entity;
     if (!$group->isNew()) {
         $form['#title'] = $this->t('Edit group %label', array('%label' => $group->label()));
     }
     $form = parent::form($form, $form_state, $group);
     return $form;
 }
Beispiel #16
0
 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $feed = $this->entity;
     // @todo: convert to a language selection widget defined in the base field.
     //   Blocked on https://drupal.org/node/2226493 which adds a generic
     //   language widget.
     $form['langcode'] = array('#title' => $this->t('Language'), '#type' => 'language_select', '#default_value' => $feed->language()->id, '#languages' => LanguageInterface::STATE_ALL, '#weight' => -4);
     return parent::form($form, $form_state, $feed);
 }
 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     /** @var \Drupal\contact\MessageInterface $message */
     $message = $this->entity;
     $form = parent::form($form, $form_state, $message);
     $form['name'] = array('#type' => 'textfield', '#title' => $this->t('Author name'), '#maxlength' => 255, '#default_value' => $message->getSenderName());
     $form['mail'] = array('#type' => 'email', '#title' => $this->t('Sender email address'), '#default_value' => $message->getSenderMail());
     return $form;
 }
Beispiel #18
0
 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $form = parent::form($form, $form_state);
     /** @var \Drupal\redirect\Entity\Redirect $redirect */
     $redirect = $this->entity;
     $default_code = $redirect->getStatusCode() ? $redirect->getStatusCode() : \Drupal::config('redirect.settings')->get('default_status_code');
     $form['status_code'] = array('#type' => 'select', '#title' => t('Redirect status'), '#description' => t('You can find more information about HTTP redirect status codes at <a href="@status-codes">@status-codes</a>.', array('@status-codes' => 'http://en.wikipedia.org/wiki/List_of_HTTP_status_codes#3xx_Redirection')), '#default_value' => $default_code, '#options' => redirect_status_code_options());
     return $form;
 }
 /**
  * Overrides Drupal\Core\Entity\EntityFormController::form().
  */
 public function form(array $form, array &$form_state)
 {
     /* @var $entity \Drupal\foo_bar\Entity\FooBar */
     $form = parent::form($form, $form_state);
     $entity = $this->entity;
     $form['user_id'] = array('#type' => 'textfield', '#title' => 'UID', '#default_value' => $entity->user_id->target_id, '#size' => 60, '#maxlength' => 128, '#required' => TRUE, '#weight' => -10);
     $form['langcode'] = array('#title' => t('Language'), '#type' => 'language_select', '#default_value' => $entity->getUntranslated()->language()->id, '#languages' => Language::STATE_ALL);
     $form['type'] = array('#type' => 'hidden', '#default_value' => $entity->getEntityTypeId());
     return $form;
 }
Beispiel #20
0
 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $form = parent::form($form, $form_state);
     $entity = $this->entity;
     // @todo: Is there a better way to check if an entity type is revisionable?
     if ($entity->getEntityType()->hasKey('revision') && !$entity->isNew()) {
         $form['revision'] = array('#type' => 'checkbox', '#title' => t('Create new revision'), '#default_value' => $entity->isNewRevision());
     }
     return $form;
 }
Beispiel #21
0
 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $workspace = $this->entity;
     $form = parent::form($form, $form_state, $workspace);
     if ($this->operation == 'edit') {
         $form['#title'] = $this->t('Edit workspace %label', array('%label' => $workspace->label()));
     }
     $form['label'] = array('#type' => 'textfield', '#title' => $this->t('Label'), '#maxlength' => 255, '#default_value' => $workspace->label(), '#description' => $this->t("Label for the Endpoint."), '#required' => TRUE);
     $form['machine_name'] = array('#type' => 'machine_name', '#title' => $this->t('Workspace ID'), '#maxlength' => 255, '#default_value' => $workspace->get('machine_name')->value, '#machine_name' => array('exists' => '\\Drupal\\multiversion\\Entity\\Workspace::load'), '#element_validate' => array());
     return $form;
 }
 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $form = parent::form($form, $form_state);
     $entity = $this->entity;
     $form['langcode'] = array('#title' => t('Language'), '#type' => 'language_select', '#default_value' => $entity->getUntranslated()->language()->getId(), '#languages' => LanguageInterface::STATE_ALL);
     // @todo: Is there a better way to check if an entity type is revisionable?
     if ($entity->getEntityType()->hasKey('revision') && !$entity->isNew()) {
         $form['revision'] = array('#type' => 'checkbox', '#title' => t('Create new revision'), '#default_value' => $entity->isNewRevision());
     }
     return $form;
 }
Beispiel #23
0
 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $form = parent::form($form, $form_state);
     $default = $this->entity->getMenuName() . ':' . $this->entity->getParentId();
     $id = $this->entity->isNew() ? '' : $this->entity->getPluginId();
     $form['menu_parent'] = $this->menuParentSelector->parentSelectElement($default, $id);
     $form['menu_parent']['#weight'] = 10;
     $form['menu_parent']['#title'] = $this->t('Parent link');
     $form['menu_parent']['#description'] = $this->t('The maximum depth for a link and all its children is fixed. Some menu links may not be available as parents if selecting them would exceed this limit.');
     $form['menu_parent']['#attributes']['class'][] = 'menu-title-select';
     return $form;
 }
Beispiel #24
0
  /**
   * {@inheritdoc}
   */
  public function form(array $form, FormStateInterface $form_state) {

    $form['advanced'] = array(
      '#type' => 'vertical_tabs',
      '#attributes' => array('class' => array('entity-meta')),
      '#weight' => 99,
    );
    $form = parent::form($form, $form_state);

    $form['payment_status'] = array(
      '#type' => 'details',
      '#title' => t('Payment status'),
      '#group' => 'advanced',
      '#attributes' => array(
        'class' => array('order-form-order-status'),
      ),
      '#attached' => array(
        'library' => array('commerce_order/drupal.commerce_order'),
      ),
      '#weight' => 90,
      '#optional' => TRUE,
    );

    if (isset($form['status'])) {
      $form['status']['#group'] = 'payment_status';
    }

    // Payment info authoring information for administrators.
    $form['author'] = array(
      '#type' => 'details',
      '#title' => t('Authoring information'),
      '#group' => 'advanced',
      '#attributes' => array(
        'class' => array('order-form-author'),
      ),
      '#attached' => array(
        'library' => array('commerce_order/drupal.commerce_order'),
      ),
      '#weight' => 91,
      '#optional' => TRUE,
    );

    if (isset($form['uid'])) {
      $form['uid']['#group'] = 'author';
    }

    if (isset($form['created'])) {
      $form['created']['#group'] = 'author';
    }

    return $form;
  }
Beispiel #25
0
 /**
  * Overrides Drupal\Core\Entity\EntityFormController::form().
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     /* @var $entity \Drupal\commerce_store\Entity\Store */
     $form = parent::form($form, $form_state);
     $entity = $this->entity;
     $default_store = $this->storage->loadDefault();
     $isDefault = TRUE;
     if ($default_store && $default_store->uuid() != $entity->uuid()) {
         $isDefault = FALSE;
     }
     $form['default'] = ['#type' => 'checkbox', '#title' => $this->t('Default'), '#default_value' => $isDefault, '#disabled' => $isDefault || empty($default_store), '#weight' => 99];
     return $form;
 }
Beispiel #26
0
 /**
  * Overrides Drupal\Core\Entity\EntityForm::form().
  */
 public function form(array $form, array &$form_state)
 {
     $form = parent::form($form, $form_state);
     $entity = $this->entity;
     $form['name'] = array('#type' => 'textfield', '#title' => t('Name'), '#default_value' => $entity->name->value, '#size' => 60, '#maxlength' => 128, '#required' => TRUE, '#weight' => -10);
     $form['user_id'] = array('#type' => 'textfield', '#title' => 'UID', '#default_value' => $entity->user_id->target_id, '#size' => 60, '#maxlength' => 128, '#required' => TRUE, '#weight' => -10);
     $form['langcode'] = array('#title' => t('Language'), '#type' => 'language_select', '#default_value' => $entity->getUntranslated()->language()->id, '#languages' => LanguageInterface::STATE_ALL);
     // @todo: Is there a better way to check if an entity type is revisionable?
     if ($entity->getEntityType()->hasKey('revision') && !$entity->isNew()) {
         $form['revision'] = array('#type' => 'checkbox', '#title' => t('Create new revision'), '#default_value' => $entity->isNewRevision());
     }
     return $form;
 }
 /**
  * This function is called by buildForm().
  * Caveat: !! It is not declared in the EntityFormInterface !!
  *
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     // Call parent to get (extra) fields.
     // This might cause baseFieldDefinitions to appear twice.
     $form = parent::form($form, $form_state);
     /* @var $transition WorkflowTransitionInterface */
     $transition = $this->entity;
     // Do not pass the element, but the form.
     // $element['#default_value'] = $transition;
     // $form += WorkflowTransitionElement::transitionElement($element, $form_state, $form);
     //
     // Pass the form via parameter
     $form['#default_value'] = $transition;
     $form = WorkflowTransitionElement::transitionElement($form, $form_state, $form);
     return $form;
 }
  /**
   * {@inheritdoc}
   */
  public function form(array $form, FormStateInterface $form_state) {
    /*
    $route = $this->getRequest()->get('_route');

    if (!$this->entity->isNew() && $this->currentUser()->id() != $this->entity->getAuthor()->id()) {
      $this->setOperation('submit');
    }
    */
    $form = parent::form($form, $form_state);
    if ($this->entity->isNew()) {
      $form['revision_uid'] = array(
        '#type' => 'value',
        '#value' => $this->currentUser()->id(),
      );
    }
    return $form;
  }
Beispiel #29
0
 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $term = $this->entity;
     $vocab_storage = $this->entityManager->getStorage('taxonomy_vocabulary');
     $vocabulary = $vocab_storage->load($term->bundle());
     $parent = array_keys(taxonomy_term_load_parents($term->id()));
     $form_state['taxonomy']['parent'] = $parent;
     $form_state['taxonomy']['vocabulary'] = $vocabulary;
     $language_configuration = $this->moduleHandler->moduleExists('language') ? language_get_default_configuration('taxonomy_term', $vocabulary->id()) : FALSE;
     $form['langcode'] = array('#type' => 'language_select', '#title' => $this->t('Language'), '#languages' => LanguageInterface::STATE_ALL, '#default_value' => $term->getUntranslated()->language()->id, '#access' => !empty($language_configuration['language_show']));
     $form['relations'] = array('#type' => 'details', '#title' => $this->t('Relations'), '#open' => $vocabulary->hierarchy == TAXONOMY_HIERARCHY_MULTIPLE, '#weight' => 10);
     // taxonomy_get_tree and taxonomy_term_load_parents may contain large
     // numbers of items so we check for taxonomy.settings:override_selector
     // before loading the full vocabulary. Contrib modules can then intercept
     // before hook_form_alter to provide scalable alternatives.
     if (!$this->config('taxonomy.settings')->get('override_selector')) {
         $parent = array_keys(taxonomy_term_load_parents($term->id()));
         $children = taxonomy_get_tree($vocabulary->id(), $term->id());
         // A term can't be the child of itself, nor of its children.
         foreach ($children as $child) {
             $exclude[] = $child->tid;
         }
         $exclude[] = $term->id();
         $tree = taxonomy_get_tree($vocabulary->id());
         $options = array('<' . $this->t('root') . '>');
         if (empty($parent)) {
             $parent = array(0);
         }
         foreach ($tree as $item) {
             if (!in_array($item->tid, $exclude)) {
                 $options[$item->tid] = str_repeat('-', $item->depth) . $item->name;
             }
         }
         $form['relations']['parent'] = array('#type' => 'select', '#title' => $this->t('Parent terms'), '#options' => $options, '#default_value' => $parent, '#multiple' => TRUE);
     }
     $form['relations']['weight'] = array('#type' => 'textfield', '#title' => $this->t('Weight'), '#size' => 6, '#default_value' => $term->getWeight(), '#description' => $this->t('Terms are displayed in ascending order by weight.'), '#required' => TRUE);
     $form['vid'] = array('#type' => 'value', '#value' => $vocabulary->id());
     $form['tid'] = array('#type' => 'value', '#value' => $term->id());
     if ($term->isNew()) {
         $form_state['redirect'] = current_path();
     }
     return parent::form($form, $form_state, $term);
 }
Beispiel #30
0
 public function form(array $form, FormStateInterface $form_state)
 {
     $form = parent::form($form, $form_state);
     /*
         // Move the revision log to be immediately after the body,
         // first moving all other items after body along to make way.
         $bodyWeight = $form['body']['#weight'];
         foreach ($form as $elementName => $elementArray) {
           if (isset($elementArray['#weight'])) {
             if ($elementArray['#weight'] > $bodyWeight) {
               $form[$elementName]['#weight'] = $form[$elementName]['#weight'] + 1;
             }
           }
         }
         $form['revision_log']['#weight'] = $bodyWeight + 1;
     */
     $form['comment'] = array('#type' => 'text_format', '#title' => 'Make a comment', '#allowed_formats' => ['basic_html'], '#rows' => 4, '#weight' => '100');
     //$form['menu']['#access']=FALSE;
     $form['revision_log']['#access'] = FALSE;
     $form['actions']['delete']['#access'] = FALSE;
     /*
         $form['revision_log']['#states'] = [
           'visible' => [
             ':textarea[name="body[0][value]"]' => [
               'data-editor-value-is-changed' => 'true'
             ],
           ],
         ];
     */
     //$form['#attached']['library'][] = 'ahs_discussions/revision_log';
     //$form['comment'] = $node->field_kbk->view(array('type' => 'some_formatter'));
     // Access is denied to the comments field
     // for user who are not administrators. This is because
     // this is technically the node edit form where comments are
     // normally administered not displayed, and so the 'administer comments'
     // permission is being used not the 'access comments' permission.
     $user = \Drupal::currentUser();
     if ($user->hasPermission('access comments')) {
         $form['field_comments_with_changes']['#access'] = TRUE;
     }
     return $form;
 }