Esempio n. 1
0
 /**
  * {@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;
 }
Esempio n. 2
0
  /**
   * {@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;
  }
Esempio n. 3
0
 /**
  * {@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;
 }
Esempio n. 4
0
 /**
  * {@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;
 }
Esempio n. 5
0
 /**
  * {@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;
 }
 /**
  * {@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;
 }
 /**
  * {@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;
 }
Esempio n. 8
0
  /**
   * 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;
  }
  /**
   * {@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;
  }
 /**
  * {@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;
 }
Esempio n. 11
0
 /**
  * {@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;
 }
Esempio n. 12
0
 /**
  * {@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;
 }
Esempio n. 13
0
 /**
  * {@inheritdoc}
  */
 protected function actions(array $form, FormStateInterface $form_state)
 {
     $actions = parent::actions($form, $form_state);
     $actions['submit']['#value'] = $this->t('Save Activity');
     return $actions;
 }
Esempio n. 14
0
  /**
   * {@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;
  }
 /**
  * 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;
 }
Esempio n. 16
0
 /**
  * {@inheritdoc}
  */
 protected function actions(array $form, FormStateInterface $form_state)
 {
     $actions = parent::actions($form, $form_state);
     $actions['submit']['#value'] = $this->t('Save @contact_type', array('@contact_type' => $this->entity->get('type')->entity->label()));
     return $actions;
 }
Esempio n. 17
0
 /**
  * {@inheritdoc}
  */
 public function actions(array $form, FormStateInterface $form_state)
 {
     $elements = parent::actions($form, $form_state);
     $elements['submit']['#value'] = $this->t('Send message');
     $elements['preview'] = array('#type' => 'submit', '#value' => $this->t('Preview'), '#submit' => array('::submitForm', '::preview'));
     return $elements;
 }
Esempio n. 18
0
 /**
  * {@inheritdoc}
  */
 protected function actions(array $form, FormStateInterface $form_state)
 {
     $actions = parent::actions($form, $form_state);
     $actions['submit']['#value'] = t('Save as draft');
     $actions['preview'] = array('#type' => 'submit', '#value' => t('Preview content'), '#submit' => array('::submitForm', '::preview'));
     return $actions;
 }
Esempio n. 19
0
 /**
  * {@inheritdoc}
  */
 protected function actions(array $form, FormStateInterface $form_state)
 {
     $element = parent::actions($form, $form_state);
     /* @var \Drupal\comment\CommentInterface $comment */
     $comment = $this->entity;
     $entity = $comment->getCommentedEntity();
     $field_definition = $this->entityManager->getFieldDefinitions($entity->getEntityTypeId(), $entity->bundle())[$comment->getFieldName()];
     $preview_mode = $field_definition->getSetting('preview');
     // No delete action on the comment form.
     unset($element['delete']);
     // Mark the submit action as the primary action, when it appears.
     $element['submit']['#button_type'] = 'primary';
     // Only show the save button if comment previews are optional or if we are
     // already previewing the submission.
     $element['submit']['#access'] = $comment->id() && $this->currentUser->hasPermission('administer comments') || $preview_mode != DRUPAL_REQUIRED || $form_state->get('comment_preview');
     $element['preview'] = array('#type' => 'submit', '#value' => $this->t('Preview'), '#access' => $preview_mode != DRUPAL_DISABLED, '#submit' => array('::submitForm', '::preview'));
     return $element;
 }
 /**
  * Returns an array of supported actions for the current entity form.
  * Caveat: !! It is not declared in the EntityFormInterface !!
  * @param array $form
  * @param \Drupal\Core\Form\FormStateInterface $form_state
  * @return
  */
 protected function actions(array $form, FormStateInterface $form_state)
 {
     // N.B. Keep code aligned: workflow_form_alter(), WorkflowTransitionForm::actions().
     $actions = parent::actions($form, $form_state);
     // A default button is provided by core. Override it.
     $actions['submit']['#value'] = t('Update workflow');
     $actions['submit']['#attributes'] = array('class' => array('form-save-default-button'));
     if (!_workflow_use_action_buttons()) {
         // Change the default submit button on the Workflow History tab.
         return $actions;
     } else {
         // Action buttons are activated.
         // Find the first workflow.
         // (So this won't work with multiple workflows per entity.)
         $workflow_form =& $form;
         // Quit if there is no Workflow on this page.
         if (!$workflow_form) {
             return;
         }
         // Quit if there are no Workflow Action buttons.
         // (If user has only 1 workflow option, there are no Action buttons.)
         if (count($workflow_form['to_sid']['#options']) <= 1) {
             return;
         }
         // Place the buttons. Remove the default 'Save' button.
         // $actions += _workflow_transition_form_get_action_buttons($form, $workflow_form);
         // Remove the default submit button from the form.
         // unset($actions['submit']);
         $default_submit_action = $actions['submit'];
         $actions = _workflow_transition_form_get_action_buttons($form, $workflow_form, $default_submit_action);
         foreach ($actions as $key => &$action) {
             $action['#submit'] = $default_submit_action['#submit'];
         }
     }
     return $actions;
 }