本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}