当前位置: 首页>>代码示例>>PHP>>正文


PHP ContentEntityForm::form方法代码示例

本文整理汇总了PHP中Drupal\Core\Entity\ContentEntityForm::form方法的典型用法代码示例。如果您正苦于以下问题:PHP ContentEntityForm::form方法的具体用法?PHP ContentEntityForm::form怎么用?PHP ContentEntityForm::form使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drupal\Core\Entity\ContentEntityForm的用法示例。


在下文中一共展示了ContentEntityForm::form方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: form

 /**
  * {@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;
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:35,代码来源:MessageForm.php

示例2: form

  public function form(array $form, FormStateInterface $form_state) {
    $form = parent::form($form, $form_state);

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

    return $form;
  }
开发者ID:AshishNaik021,项目名称:iimisac-d8,代码行数:7,代码来源:FillPdfFormFieldForm.php

示例3: form

 /**
  * {@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;
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:10,代码来源:ShortcutForm.php

示例4: form

  /**
   * {@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;
  }
开发者ID:jkyto,项目名称:agolf,代码行数:38,代码来源:EntitySubqueueForm.php

示例5: 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;
 }
开发者ID:aritnath1990,项目名称:simplenewslatest,代码行数:28,代码来源:SubscriberForm.php

示例6: 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);
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:10,代码来源:PaymentForm.php

示例7: form

 /**
  * {@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;
 }
开发者ID:mglaman,项目名称:drupalcamp-base,代码行数:29,代码来源:EnhancedContentEntityFormBase.php

示例8: form

 /**
  * {@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;
 }
开发者ID:marmouset,项目名称:drupal,代码行数:33,代码来源:ProductForm.php

示例9: form

 /**
  * {@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;
 }
开发者ID:sedurzu,项目名称:ildeposito8,代码行数:31,代码来源:MediaForm.php

示例10: 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);
 }
开发者ID:darrylri,项目名称:protovbmwmo,代码行数:36,代码来源:FieldCollectionItemForm.php

示例11: form

 /**
  * {@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;
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:37,代码来源:MessageForm.php

示例12: form

  /**
   * {@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;
  }
开发者ID:housineali,项目名称:drpl8_dv,代码行数:62,代码来源:OrderForm.php

示例13: form

 /**
  * {@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);
 }
开发者ID:wallecan,项目名称:drupalpp,代码行数:11,代码来源:ReservationForm.php

示例14: form

 /**
  * {@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);
 }
开发者ID:justincletus,项目名称:webdrupalpro,代码行数:12,代码来源:RuleComponentForm.php

示例15: form

 /**
  * {@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;
 }
开发者ID:justincletus,项目名称:webdrupalpro,代码行数:12,代码来源:GroupForm.php


注:本文中的Drupal\Core\Entity\ContentEntityForm::form方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。