• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Entity\ContentEntityForm类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     parent::submitForm($form, $form_state);
     // The subscriptions field has properties which are set to NULL by ordinary
     // saving, which is wrong. The Subscriber::(un)subscribe() methods save the
     // values correctly. For each newsletter ID we check if it exists in
     // current subscriptions and new subscriptions respectively.
     $current_subscriptions = $this->entity->getSubscribedNewsletterIds();
     $subscription_values = $form_state->getValue('subscriptions');
     $new_subscriptions = array();
     foreach ($subscription_values as $subscription_value) {
         array_push($new_subscriptions, $subscription_value['target_id']);
     }
     foreach (array_keys(simplenews_newsletter_get_visible()) as $newsletter) {
         if (in_array($newsletter, $current_subscriptions) && !in_array($newsletter, $new_subscriptions)) {
             $this->entity->unsubscribe($newsletter);
         } elseif (!in_array($newsletter, $current_subscriptions) && in_array($newsletter, $new_subscriptions)) {
             $this->entity->subscribe($newsletter);
         }
     }
     $form_state->setRedirect('view.simplenews_subscribers.page_1');
     if ($this->entity->isNew()) {
         drupal_set_message($this->t('Subscriber %label has been added.', array('%label' => $this->entity->label())));
     } else {
         drupal_set_message($this->t('Subscriber %label has been updated.', array('%label' => $this->entity->label())));
     }
 }
开发者ID:aritnath1990,项目名称:simplenewslatest,代码行数:30,代码来源:SubscriberForm.php


示例2: validate

 /**
  * {@inheritdoc}
  */
 public function validate(array $form, FormStateInterface $form_state)
 {
     if (!$this->pathValidator->isValid($form_state->getValue('path'))) {
         $form_state->setErrorByName('path', $this->t('The shortcut must correspond to a valid path on the site.'));
     }
     parent::validate($form, $form_state);
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:10,代码来源:ShortcutForm.php


示例3: actions

 /**
  * {@inheritdoc}
  */
 protected function actions(array $form, FormStateInterface $form_state)
 {
     $actions = parent::actions($form, $form_state);
     $actions['submit']['#value'] = $this->t('Save task');
     $actions['submit']['#access'] = \Drupal::currentUser()->hasPermission('administer tmgmt') || \Drupal::currentUser()->hasPermission('administer translation tasks');
     return $actions;
 }
开发者ID:andrewl,项目名称:andrewlnet,代码行数:10,代码来源:LocalTaskForm.php


示例4: submit

 /**
  * Overrides \Drupal\Core\Entity\EntityFormController::submit().
  */
 public function submit(array $form, array &$form_state)
 {
     // Build the entity object from the submitted values.
     $entity = parent::submit($form, $form_state);
     $form_state['redirect_route']['route_name'] = 'foo_bar.list';
     return $entity;
 }
开发者ID:bnchdrff,项目名称:foo_bar,代码行数:10,代码来源:FooBarFormController.php


示例5: validate

 /**
  * {@inheritdoc}
  */
 public function validate(array $form, FormStateInterface $form_state)
 {
     if (!shortcut_valid_link($form_state['values']['path'])) {
         $form_state->setErrorByName('path', $this->t('The shortcut must correspond to a valid path on the site.'));
     }
     parent::validate($form, $form_state);
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:10,代码来源:ShortcutForm.php


示例6: actions

  /**
   * {@inheritdoc}
   */
  public function actions(array $form, FormStateInterface $form_state) {
    $actions = parent::actions($form, $form_state);

    if ($this->entity->isNew()) {
      $actions['submit']['#value'] = $this->t('Create Flagging');
    }
    else {
      $actions['submit']['#value'] = $this->t('Update Flagging');
    }

    // Customize the delete link.
    if (isset($actions['delete'])) {
      // @todo Why does the access call always fail?
      unset($actions['delete']['#access']);

      $actions['delete']['#title'] = $this->t('Delete Flagging');

      // Build the delete url from route. We need to build this manually
      // otherwise Drupal will try to build the flagging entity's delete-form
      // link. Since that route doesn't use the flagging ID, Drupal can't build
      // the link for us.
      $route_params = [
        'flag' => $this->entity->getFlagId(),
        'entity_id' => $this->entity->getFlaggableId(),
        'destination' => \Drupal::request()->get('destination'),
      ];
      $url = Url::fromRoute('flag.confirm_unflag', $route_params);

      $actions['delete']['#url'] = $url;
    }

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


示例7: 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


示例8: 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


示例9: actions

 /**
  * {@inheritdoc}
  */
 protected function actions(array $form, FormStateInterface $form_state)
 {
     $actions = parent::actions($form, $form_state);
     $actions['submit']['#value'] = $this->entity->book['original_bid'] ? $this->t('Update book outline') : $this->t('Add to book outline');
     $actions['delete']['#value'] = $this->t('Remove from book outline');
     $actions['delete']['#access'] = $this->bookManager->checkNodeIsRemovable($this->entity);
     return $actions;
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:11,代码来源:BookOutlineForm.php


示例10: 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


示例11: actions

 /**
  * {@inheritdoc}
  */
 protected function actions(array $form, array &$form_state)
 {
     $actions = parent::actions($form, $form_state);
     $actions['submit']['#value'] = $this->getConfirmText();
     unset($actions['delete']);
     // Prepare cancel link.
     $actions['cancel'] = ConfirmFormHelper::buildCancelLink($this, $this->getRequest());
     return $actions;
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:12,代码来源:ContentEntityConfirmFormBase.php


示例12: submitForm

 /**
  * {@inheritdoc}
  *
  * Always create a new revision
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     // Build the node object from the submitted values.
     parent::submitForm($form, $form_state);
     // Set new revision if needed
     if ($this->entity->id()) {
         $this->setNewRevision($form_state);
     }
 }
开发者ID:shrimala,项目名称:ahsweb,代码行数:14,代码来源:DiscussionForm.php


示例13: 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


示例14: form

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


示例15: buildEntity

 /**
  * {@inheritdoc}
  */
 public function buildEntity(array $form, FormStateInterface $form_state)
 {
     $term = parent::buildEntity($form, $form_state);
     // Prevent leading and trailing spaces in term names.
     $term->setName(trim($term->getName()));
     // Assign parents with proper delta values starting from 0.
     $term->parent = array_keys($form_state->getValue('parent'));
     return $term;
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:12,代码来源:TermForm.php


示例16: form

 /**
  * {@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;
 }
开发者ID:jeyram,项目名称:camp-gdl,代码行数:13,代码来源:EntityTestForm.php


示例17: submit

 /**
  * Overrides \Drupal\Core\Entity\EntityForm::submit().
  */
 public function submit(array $form, array &$form_state)
 {
     // Build the entity object from the submitted values.
     $entity = parent::submit($form, $form_state);
     // Save as a new revision if requested to do so.
     if (!empty($form_state['values']['revision'])) {
         $entity->setNewRevision();
     }
     return $entity;
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:13,代码来源:EntityTestForm.php


示例18: save

  public function save(array $form, FormStateInterface $form_state) {
    /** @var FillPdfFormInterface $entity */
    $entity = $this->entity;

    $form_state->setRedirect('entity.fillpdf_form.edit_form', [
      'fillpdf_form' => $this->entity->fillpdf_form->target_id,
    ]);

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


示例19: 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;
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:14,代码来源:EntityTestForm.php


示例20: flagViolations

 /**
  * {@inheritdoc}
  */
 protected function flagViolations(EntityConstraintViolationListInterface $violations, array $form, FormStateInterface $form_state)
 {
     // Manually flag violations of fields not handled by the form display. This
     // is necessary as entity form displays only flag violations for fields
     // contained in the display.
     $field_names = array('label', 'machine_name');
     foreach ($violations->getByFields($field_names) as $violation) {
         list($field_name) = explode('.', $violation->getPropertyPath(), 2);
         $form_state->setErrorByName($field_name, $violation->getMessage());
     }
     parent::flagViolations($violations, $form, $form_state);
 }
开发者ID:sedurzu,项目名称:ildeposito8,代码行数:15,代码来源:WorkspaceForm.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Entity\ContentEntityInterface类代码示例发布时间:2022-05-23
下一篇:
PHP Entity\ContentEntityBase类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap