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


PHP ContentEntityForm::buildForm方法代码示例

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


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

示例1: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     /* @var $entity \Drupal\drupalbristol_sponsors\Entity\SponsorEntity */
     $form = parent::buildForm($form, $form_state);
     $entity = $this->entity;
     return $form;
 }
开发者ID:drupalbristol,项目名称:drupal-bristol-website,代码行数:10,代码来源:SponsorEntityForm.php

示例2: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $config = $this->entity->getConfiguration();
     $manager = $this->entity->getType() == 'condition' ? 'conditionManager' : 'actionManager';
     $this->plugin = $this->{$manager}->createInstance($this->entity->getPluginId(), $config);
     return parent::buildForm($form, $form_state);
 }
开发者ID:justincletus,项目名称:webdrupalpro,代码行数:10,代码来源:RuleComponentForm.php

示例3: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     /* @var $entity \Drupal\component\Entity\Component */
     $form = parent::buildForm($form, $form_state);
     $entity = $this->entity;
     return $form;
 }
开发者ID:poetic,项目名称:clutch,代码行数:10,代码来源:ComponentForm.php

示例4: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     /* @var $entity \Drupal\drupal8_entity\Entity\Drupal8EntityItem */
     $form = parent::buildForm($form, $form_state);
     $entity = $this->entity;
     $form['langcode'] = array('#title' => $this->t('Language'), '#type' => 'language_select', '#default_value' => $entity->langcode->value, '#languages' => Language::STATE_ALL);
     return $form;
 }
开发者ID:mgrimard,项目名称:drupal8_entity,代码行数:11,代码来源:Drupal8EntityItemForm.php

示例5: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     /* @var $entity \Drupal\content_entity_example\Entity\Contact */
     $form = parent::buildForm($form, $form_state);
     $entity = $this->entity;
     $form['langcode'] = array('#title' => $this->t('Language'), '#type' => 'language_select', '#default_value' => $entity->getUntranslated()->language()->getId(), '#languages' => Language::STATE_ALL);
     return $form;
 }
开发者ID:hugronaphor,项目名称:cornel,代码行数:11,代码来源:ContactForm.php

示例6: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $form = parent::buildForm($form, $form_state);
     // The widgets are allowed to signal that the form should be hidden
     // (because there's no purchasable entity to select, for example).
     if ($form_state->get('hide_form')) {
         $form['#access'] = FALSE;
     }
     return $form;
 }
开发者ID:alexburrows,项目名称:cream-2.x,代码行数:13,代码来源:AddToCartForm.php

示例7: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     parent::buildForm($form, $form_state);
     $roles = tmgmt_local_translator_roles();
     if (empty($roles)) {
         drupal_set_message(t('No user role has the "provide translation services" permission. <a href="@url">Configure permissions</a> for the Drupal user module.', array('@url' => URL::fromRoute('user.admin_permissions'))), 'warning');
     }
     $form['tuid'] = array('#title' => t('Assign to'), '#type' => 'select', '#empty_option' => t('- Select user -'), '#options' => tmgmt_local_get_assignees_for_tasks([$this->getEntity()->id()]), '#required' => TRUE);
     $form['actions']['#type'] = 'actions';
     $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Assign tasks'));
     return $form;
 }
开发者ID:andrewl,项目名称:andrewlnet,代码行数:15,代码来源:LocalTaskAssignForm.php

示例8: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     /* @var $entity \Drupal\custom_page\Entity\CustomPage */
     $form = parent::buildForm($form, $form_state);
     $entity = $this->entity;
     $form['metatags'] = array('#type' => 'details', '#title' => 'Meta tags');
     $form['metatags']['meta_title'] = $form['meta_title'];
     $form['metatags']['meta_description'] = $form['meta_description'];
     unset($form['meta_title']);
     unset($form['meta_description']);
     return $form;
 }
开发者ID:poetic,项目名称:clutch,代码行数:15,代码来源:CustomPageForm.php

示例9: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     // Skip building the form if there are no available stores.
     $store_query = $this->entityManager->getStorage('commerce_store')->getQuery();
     if ($store_query->count()->execute() == 0) {
         $options = ['query' => ['destination' => Url::fromRoute('<current>')->toString()]];
         $link = Link::createFromRoute('Add a new store.', 'entity.commerce_store.add_page', [], $options);
         $form['warning'] = ['#markup' => t("Products can't be created until a store has been added. @link", ['@link' => $link->toString()])];
         return $form;
     }
     return parent::buildForm($form, $form_state);
 }
开发者ID:alexburrows,项目名称:cream-2.x,代码行数:15,代码来源:ProductForm.php

示例10: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $form = parent::buildForm($form, $form_state);
     $form['#title'] = $this->getQuestion();
     $form['#attributes']['class'][] = 'confirmation';
     $form['description'] = array('#markup' => $this->getDescription());
     $form[$this->getFormName()] = array('#type' => 'hidden', '#value' => 1);
     // By default, render the form using theme_confirm_form().
     if (!isset($form['#theme'])) {
         $form['#theme'] = 'confirm_form';
     }
     return $form;
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:16,代码来源:ContentEntityConfirmFormBase.php

示例11: buildForm

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    /* @var $entity \Drupal\product_search\Entity\PoliticalDivision */
    $form = parent::buildForm($form, $form_state);
    $entity = $this->entity;

    $form['langcode'] = array(
      '#title' => $this->t('Language'),
      '#type' => 'language_select',
      '#default_value' => $entity->getUntranslated()->language()->getId(),
      '#languages' => Language::STATE_ALL,
    );

    return $form;
  }
开发者ID:Koalasoft,项目名称:product_search,代码行数:17,代码来源:PoliticalDivisionForm.php

示例12: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     /* @var $entity \Drupal\myeck\Entity\Myeck */
     $form = parent::buildForm($form, $form_state);
     //сделать универсальное для всех !!!!!!!!!!!!!!!
     //    $entity = $this->entity;
     //    $form['langcode'] = array(
     //      '#title' => $this->t('Language'),
     //      '#type' => 'language_select',
     //      '#default_value' => $entity->getUntranslated()->language()->getId(),
     //      '#languages' => Language::STATE_ALL,
     //    );
     return $form;
 }
开发者ID:alexawg2015,项目名称:drupal-8,代码行数:17,代码来源:MyeckForm.php

示例13: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     /* @var $entity \Drupal\quiz\Entity\Answer */
     $form = parent::buildForm($form, $form_state);
     $entity = $this->entity;
     $question = $entity->getQuestion();
     /* @var $question \Drupal\quiz\Entity\Question */
     $question = $entity->getQuestion();
     /* @var $question \Drupal\quiz\Entity\Question */
     $quiz = $question->getQuiz();
     $status = $quiz->getActiveStatus($this->currentUser());
     /* @var $status \Drupal\quiz\Entity\UserQuizStatus */
     if ($status == NULL) {
         return $this->redirect('entity.quiz.canonical_user', ['quiz' => $question->getQuiz()->id()]);
     }
     if ($status->getCurrentQuestionId() != $question->id()) {
         return $this->redirect('entity.quiz.canonical_user', ['quiz' => $question->getQuiz()->id()]);
     }
     $count = $question->getUserQuizStateAnswersCount($this->currentUser(), $status);
     if ($count) {
         $status->setLastQuestion($question);
         $status->save();
         return $this->redirect('entity.quiz.canonical_user', ['quiz' => $question->getQuiz()->id()]);
     }
     $form['langcode'] = array('#title' => $this->t('Language'), '#type' => 'language_select', '#default_value' => $entity->langcode->value, '#languages' => Language::STATE_ALL);
     $form['question'] = array('#type' => 'label', '#title' => $entity->getQuestion()->get('question')->value, '#weight' => -5);
     // Only display a timer if the quiz is timed.
     //kint($quiz->get('time')->value);
     if ($quiz->get('time')->value > 0) {
         $form['timer'] = array('#markup' => '<div id="js-timer"></div>', '#weight' => -9);
         $timeLeft = $quiz->get('time')->value + $status->get('started')->value - time();
         //kint($timeLeft);
         // If we're out of time we mark the status as finished, no matter if some questions were left unanswered.
         if ($timeLeft < 0) {
             $status->setFinished(time());
             $status->setScore($status->evaluate());
             $status->setMaxScore($quiz->getMaxScore());
             $status->setPercent($quiz->get('percent')->value);
             $status->setFinished(time());
             $status->setQuestionsCount(count($quiz->getQuestions()));
             $status->save();
             //TODO: redirect to evaluation. And make status save a separate function in controller.
             return $this->redirect('entity.quiz.canonical', ['quiz' => $quiz->id()]);
         }
         $form['#attached']['library'][] = 'quiz/quiz.timer';
         $form['#attached']['drupalSettings']['quiz']['endtime'] = $timeLeft - 1;
     }
     return $form;
 }
开发者ID:novaFTL,项目名称:quiz-drupal8,代码行数:52,代码来源:AnswerForm.php

示例14: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     /* @var $entity \Drupal\rdf_entity\Entity\Rdf */
     $form = parent::buildForm($form, $form_state);
     $entity = $this->entity;
     $type = RdfEntityType::load($entity->bundle());
     if ($type->label()) {
         // Add.
         if ($entity->isNew()) {
             $form['#title'] = $this->t('<em>Add @type</em>', array('@type' => $type->label()));
         } else {
             $form['#title'] = $this->t('<em>Edit @type</em> @title', array('@type' => $type->label(), '@title' => $entity->label()));
         }
     }
     $form['langcode'] = array('#title' => $this->t('Language'), '#type' => 'language_select', '#default_value' => $entity->getUntranslated()->language()->getId(), '#languages' => Language::STATE_ALL);
     return $form;
 }
开发者ID:ec-europa,项目名称:joinup-dev,代码行数:20,代码来源:RdfForm.php

示例15: buildForm

 /**
  * {@inheritDoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $entity = $this->entity;
     $state = \Drupal::state();
     $form = parent::buildForm($form, $form_state);
     // Due to #limit_validation_errors, submitting the form with the "Add" button
     // will only expose validated values in the submit handler, so our storage may
     // be incomplete. Therefore, the default values always have to be overloaded.
     $stored_record = $entity->getStorageRecord();
     $stored_record += array('exclude' => '', 'parent' => array('child' => ''), 'field' => array());
     $storage = $form_state->get('mollom_test');
     $storage = empty($storage) ? array() : $storage;
     $stored_record = array_merge($stored_record, $storage);
     // Always add an empty field the user can submit.
     $stored_record['field']['new'] = '';
     $form_state->set('mollom_test', $stored_record);
     // Output a page view counter for page/form cache testing purposes.
     $count = $state->get('mollom_test.view_count', 0);
     $reset_link = \Drupal::l($this->t('Reset'), Url::fromRoute('mollom_test.views_reset', [], ['query' => $this->getDestinationArray()]));
     $form['views'] = array('#markup' => '<p>' . 'Views: ' . $count++ . ' ' . $reset_link . '</p>');
     $state->set('mollom_test.view_count', $count);
     // Conditionally enable form caching.
     if ($state->get('mollom_test.cache_form', FALSE)) {
         $form_state->setCached(TRUE);
     }
     $form['#tree'] = TRUE;
     $form['mid'] = array('#type' => 'hidden', '#value' => $stored_record['mid']);
     $form['title'] = array('#type' => 'textfield', '#title' => 'Title', '#default_value' => $stored_record['title'], '#required' => TRUE);
     $form['body'] = array('#type' => 'textfield', '#title' => 'Body', '#default_value' => $stored_record['body']);
     $form['exclude'] = array('#type' => 'textfield', '#title' => 'Some other field', '#default_value' => $stored_record['exclude']);
     $form['parent']['child'] = array('#type' => 'textfield', '#title' => 'Nested element', '#default_value' => $stored_record['parent']['child']);
     $form['field'] = array('#type' => 'fieldset', '#title' => 'Field');
     $weight = 0;
     foreach ($stored_record['field'] as $delta => $value) {
         $form['field'][$delta] = array('#type' => 'textfield', '#title' => 'Field ' . $delta, '#default_value' => $value, '#weight' => $weight++);
     }
     $form['field']['new']['#weight'] = 999;
     $form['field']['submit'] = array('#type' => 'submit', '#value' => 'Add', '#limit_validation_errors' => array(array('field')), '#submit' => array('::fieldSubmitForm'), '#weight' => 1000);
     $form['status'] = array('#type' => 'checkbox', '#title' => 'Published', '#default_value' => $stored_record['status'], '#access' => \Drupal::currentUser()->hasPermission('administer mollom'));
     return $form;
 }
开发者ID:ABaldwinHunter,项目名称:durhamatletico-cms,代码行数:44,代码来源:PostForm.php


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