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


PHP ContentEntityForm::actions方法代码示例

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


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

示例1: actions

 /**
  * {@inheritdoc}
  */
 protected function actions(array $form, FormStateInterface $form_state)
 {
     $element = parent::actions($form, $form_state);
     $element['submit']['#button_type'] = 'primary';
     $element['delete']['#access'] = $this->entity->access('delete');
     return $element;
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:10,代码来源:MenuLinkContentForm.php

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

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

 /**
  * {@inheritdoc}
  */
 protected function actions(array $form, FormStateInterface $form_state)
 {
     $element = parent::actions($form, $form_state);
     $element['submit']['#value'] = $this->t('Save changes');
     $element['delete']['#access'] = $this->entity->access('delete');
     return $element;
 }
开发者ID:justincletus,项目名称:webdrupalpro,代码行数:10,代码来源:OrderForm.php

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

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

示例7: actions

 /**
  * {@inheritdoc}
  */
 protected function actions(array $form, FormStateInterface $form_state)
 {
     $actions = parent::actions($form, $form_state);
     // Switch label to Subscribe for new subscribers.
     if ($this->entity->isNew()) {
         $actions['submit']['#value'] = $this->t('Subscribe');
     }
     return $actions;
 }
开发者ID:aritnath1990,项目名称:simplenewslatest,代码行数:12,代码来源:SubscriberForm.php

示例8: actions

  /**
   * Overrides Drupal\Core\Entity\EntityForm::actions().
   */
  protected function actions(array $form, FormStateInterface $form_state) {
    $element = parent::actions($form, $form_state);
    $profile = $this->entity;

    if (\Drupal::currentUser()->hasPermission('administer profiles')) {
      // Add an "Activate" button.
      $element['activate'] = $element['submit'];
      $element['activate']['#dropbutton'] = 'save';
      if ($profile->isNew()) {
        $element['activate']['#value'] = t('Save and make active');
      }
      else {
        $element['activate']['#value'] = $profile->isActive() ? t('Save and keep active') : t('Save and make active');
      }
      $element['activate']['#weight'] = 0;
      array_unshift($element['activate']['#submit'], [$this, 'activate']);

      // Add a "Deactivate" button.
      $element['deactivate'] = $element['submit'];
      $element['deactivate']['#dropbutton'] = 'save';
      if ($profile->isNew()) {
        $element['deactivate']['#value'] = t('Save as inactive');
      }
      else {
        $element['deactivate']['#value'] = !$profile->isActive() ? t('Save and keep inactive') : t('Save and make inactive');
      }
      $element['deactivate']['#weight'] = 10;
      array_unshift($element['deactivate']['#submit'], [
          $this,
          'deactivate'
        ]);

      // If already deactivated, the 'activate' button is primary.
      if ($profile->isActive()) {
        unset($element['deactivate']['#button_type']);
      }
      // Otherwise, the 'deactivate' button is primary and should come first.
      else {
        unset($element['deactivate']['#button_type']);
        $element['deactivate']['#weight'] = -10;
      }

      // Remove the "Save" button.
      $element['submit']['#access'] = FALSE;
    }

    $element['delete']['#access'] = $profile->access('delete');
    $element['delete']['#weight'] = 100;

    return $element;
  }
开发者ID:housineali,项目名称:drpl8_dv,代码行数:54,代码来源:ProfileForm.php

示例9: actions

  /**
   * {@inheritDoc}
   */
  protected function actions(array $form, FormStateInterface $form_state) {
    $actions = parent::actions($form, $form_state);
    /** @var \Drupal\eform\entity\EFormsubmission $entity */
    $entity = $this->entity;
    // Add redirect function callback.
    if (isset($actions['submit'])) {
      $actions['submit']['#submit'][] =  '::eformRedirect';
    }
    if ($entity->getEFormType()->isDraftable()) {
      $actions['draft'] = array(
        '#type' => 'submit',
        '#value' => $this->t('Save Draft'),
        '#validate' => array('::validate'),
        '#submit' => array('::submitForm', '::saveDraft', '::eformRedirect'),
        '#weight' => -100,
      );
    }

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

示例10: actions

 /**
  * {@inheritdoc}
  */
 protected function actions(array $form, FormStateInterface $form_state)
 {
     $element = parent::actions($form, $form_state);
     $entity = $this->entity;
     $element['delete']['#access'] = $entity->access('delete');
     $element['delete']['#weight'] = 100;
     // Add a "Publish" button.
     $element['publish'] = $element['submit'];
     $element['publish']['#published_status'] = TRUE;
     $element['publish']['#dropbutton'] = 'save';
     $element['publish']['#weight'] = 0;
     // Add an "Unpublish" button.
     $element['unpublish'] = $element['submit'];
     $element['unpublish']['#published_status'] = FALSE;
     $element['unpublish']['#dropbutton'] = 'save';
     $element['unpublish']['#weight'] = 10;
     // isNew | prev status » primary   & publish label             & unpublish label
     // 1     | 1           » publish   & Save and publish          & Save as unpublished
     // 1     | 0           » unpublish & Save and publish          & Save as unpublished
     // 0     | 1           » publish   & Save and keep published   & Save and unpublish
     // 0     | 0           » unpublish & Save and keep unpublished & Save and publish
     if ($entity->isNew()) {
         $element['publish']['#value'] = $this->t('Save and publish');
         $element['unpublish']['#value'] = $this->t('Save as unpublished');
     } else {
         $element['publish']['#value'] = $entity->isPublished() ? $this->t('Save and keep published') : $this->t('Save and publish');
         $element['unpublish']['#value'] = !$entity->isPublished() ? $this->t('Save and keep unpublished') : $this->t('Save and unpublish');
     }
     // Set the primary button based on the published status.
     if ($entity->isPublished()) {
         unset($element['unpublish']['#button_type']);
     } else {
         unset($element['publish']['#button_type']);
         $element['unpublish']['#weight'] = -10;
     }
     // Hide the now unneeded "Save" button.
     $element['submit']['#access'] = FALSE;
     return $element;
 }
开发者ID:mglaman,项目名称:drupalcamp-base,代码行数:42,代码来源:EnhancedContentEntityFormBase.php

示例11: actions

 /**
  * {@inheritdoc}
  */
 protected function actions(array $form, FormStateInterface $form_state)
 {
     $element = parent::actions($form, $form_state);
     $node = $this->entity;
     $preview_mode = $node->type->entity->getPreviewMode();
     $element['submit']['#access'] = $preview_mode != DRUPAL_REQUIRED || $this->hasBeenPreviewed;
     // If saving is an option, privileged users get dedicated form submit
     // buttons to adjust the publishing status while saving in one go.
     // @todo This adjustment makes it close to impossible for contributed
     //   modules to integrate with "the Save operation" of this form. Modules
     //   need a way to plug themselves into 1) the ::submit() step, and
     //   2) the ::save() step, both decoupled from the pressed form button.
     if ($element['submit']['#access'] && \Drupal::currentUser()->hasPermission('administer nodes')) {
         // isNew | prev status » default   & publish label             & unpublish label
         // 1     | 1           » publish   & Save and publish          & Save as unpublished
         // 1     | 0           » unpublish & Save and publish          & Save as unpublished
         // 0     | 1           » publish   & Save and keep published   & Save and unpublish
         // 0     | 0           » unpublish & Save and keep unpublished & Save and publish
         // Add a "Publish" button.
         $element['publish'] = $element['submit'];
         // If the "Publish" button is clicked, we want to update the status to "published".
         $element['publish']['#published_status'] = TRUE;
         $element['publish']['#dropbutton'] = 'save';
         if ($node->isNew()) {
             $element['publish']['#value'] = t('Save and publish');
         } else {
             $element['publish']['#value'] = $node->isPublished() ? t('Save and keep published') : t('Save and publish');
         }
         $element['publish']['#weight'] = 0;
         // Add a "Unpublish" button.
         $element['unpublish'] = $element['submit'];
         // If the "Unpublish" button is clicked, we want to update the status to "unpublished".
         $element['unpublish']['#published_status'] = FALSE;
         $element['unpublish']['#dropbutton'] = 'save';
         if ($node->isNew()) {
             $element['unpublish']['#value'] = t('Save as unpublished');
         } else {
             $element['unpublish']['#value'] = !$node->isPublished() ? t('Save and keep unpublished') : t('Save and unpublish');
         }
         $element['unpublish']['#weight'] = 10;
         // If already published, the 'publish' button is primary.
         if ($node->isPublished()) {
             unset($element['unpublish']['#button_type']);
         } else {
             unset($element['publish']['#button_type']);
             $element['unpublish']['#weight'] = -10;
         }
         // Remove the "Save" button.
         $element['submit']['#access'] = FALSE;
     }
     $element['preview'] = array('#type' => 'submit', '#access' => $preview_mode != DRUPAL_DISABLED && ($node->access('create') || $node->access('update')), '#value' => t('Preview'), '#weight' => 20, '#submit' => array('::submitForm', '::preview'));
     $element['delete']['#access'] = $node->access('delete');
     $element['delete']['#weight'] = 100;
     return $element;
 }
开发者ID:nsp15,项目名称:Drupal8,代码行数:58,代码来源:NodeForm.php

示例12: actions

 /**
  * {@inheritdoc}
  */
 public function actions(array $form, array &$form_state)
 {
     $elements = parent::actions($form, $form_state);
     $elements['submit']['#value'] = $this->t('Send message');
     $elements['preview'] = array('#value' => $this->t('Preview'), '#validate' => array(array($this, 'validate')), '#submit' => array(array($this, 'submit'), array($this, 'preview')));
     return $elements;
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:10,代码来源:MessageForm.php

示例13: actions

 /**
  * {@inheritdoc}
  */
 protected function actions(array $form, FormStateInterface $form_state)
 {
     $actions = parent::actions($form, $form_state);
     $actions['submit']['#value'] = $this->t('Save Activity');
     return $actions;
 }
开发者ID:jasonruyle,项目名称:crm_core,代码行数:9,代码来源:ActivityForm.php

示例14: actions

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

    $actions['reverse'] = [
      '#type' => 'submit',
      '#value' => $this->t('Reverse'),
      '#submit' => ['::submitAction'],
      '#op' => 'reverse',
      '#ajax' => [
        'callback' => '::subqueueActionAjaxForm',
        'wrapper' => $form_state->get('subqueue_form_wrapper_id'),
      ],
    ];

    $actions['shuffle'] = [
      '#type' => 'submit',
      '#value' => $this->t('Shuffle'),
      '#submit' => ['::submitAction'],
      '#op' => 'shuffle',
      '#ajax' => [
        'callback' => '::subqueueActionAjaxForm',
        'wrapper' => $form_state->get('subqueue_form_wrapper_id'),
      ],
    ];

    $actions['clear'] = [
      '#type' => 'submit',
      '#value' => $this->t('Clear'),
      '#submit' => ['::submitAction'],
      '#op' => 'clear',
      '#ajax' => [
        'callback' => '::subqueueActionAjaxForm',
        'wrapper' => $form_state->get('subqueue_form_wrapper_id'),
      ],
    ];

    return $actions;
  }
开发者ID:jkyto,项目名称:agolf,代码行数:41,代码来源:EntitySubqueueForm.php

示例15: actions

 /**
  * Returns an array of supported actions for the current entity form.
  */
 protected function actions(array $form, FormStateInterface $form_state)
 {
     // Only use the existing submit action.
     $actions = parent::actions($form, $form_state);
     $actions = ['submit' => $actions['submit']];
     $actions['submit']['#value'] = $this->t('Pay');
     $actions['submit']['#disabled'] = count($this->getPaymentMethodManager()->getDefinitions()) == 0;
     return $actions;
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:12,代码来源:PaymentForm.php


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