本文整理汇总了PHP中Drupal\Core\Entity\EntityForm::save方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityForm::save方法的具体用法?PHP EntityForm::save怎么用?PHP EntityForm::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Entity\EntityForm
的用法示例。
在下文中一共展示了EntityForm::save方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
/**
* {@inheritdoc}
*/
public function save(array $form, FormStateInterface $form_state)
{
/* @var $entity \Drupal\workflow\Entity\Workflow */
$entity = $this->entity;
// Prevent leading and trailing spaces.
$entity->set('label', trim($entity->label()));
$entity->set('options', array('name_as_title' => $form_state->getValue('name_as_title'), 'fieldset' => $form_state->getValue('fieldset'), 'options' => $form_state->getValue('options'), 'schedule_timezone' => $form_state->getValue('schedule_timezone'), 'comment_log_node' => $form_state->getValue('comment_log_node'), 'comment_log_tab' => $form_state->getValue('comment_log_tab'), 'watchdog_log' => $form_state->getValue('watchdog_log')));
$status = parent::save($form, $form_state);
$action = $status == SAVED_UPDATED ? 'updated' : 'added';
// Tell the user we've updated the data.
$args = ['%label' => $entity->label(), '%action' => $action, 'link' => $entity->link(t('Edit'))];
drupal_set_message($this->t('Workflow %label has been %action. Please maintain the permissions, states and transitions.', $args));
$this->logger('workflow')->notice('Workflow %label has been %action.', $args);
if ($status == SAVED_NEW) {
$form_state->setRedirect('entity.workflow_type.edit_form', ['workflow_type' => $entity->id()]);
}
}
示例2: save
/**
* {@inheritdoc}
*/
public function save(array $form, FormStateInterface $form_state)
{
parent::save($form, $form_state);
$form_state->setRedirectUrl($this->entity->urlInfo('edit-form'));
}
示例3: save
/**
* {@inheritdoc}
*/
public function save(array $form, FormStateInterface $form_state)
{
$status = parent::save($form, $form_state);
if ($status) {
drupal_set_message($this->t('Saved the %label Key.', array('%label' => $this->entity->label())));
} else {
drupal_set_message($this->t('The %label Key was not saved.', array('%label' => $this->entity->label())));
}
$form_state->setRedirectUrl($this->entity->urlInfo('collection'));
}
示例4: save
/**
* {@inheritDoc}
*/
public function save(array $form, FormStateInterface $form_state)
{
parent::save($form, $form_state);
drupal_set_message($this->t('Pattern @label saved.', ['@label' => $this->entity->label()]));
$form_state->setRedirectUrl($this->entity->toUrl('collection'));
}
示例5: save
/**
* {@inheritdoc}
*/
public function save(array $form, FormStateInterface $form_state)
{
/** @var \Drupal\flexslider\Entity\Flexslider $flexslider */
$flexslider = $this->entity;
$status = parent::save($form, $form_state);
switch ($status) {
case SAVED_NEW:
drupal_set_message($this->t('Created the %label FlexSlider optionset.', ['%label' => $flexslider->label()]));
break;
default:
drupal_set_message($this->t('Saved the %label FlexSlider optionset.', ['%label' => $flexslider->label()]));
}
$form_state->setRedirectUrl($flexslider->toUrl('collection'));
}
示例6: save
/**
* {@inheritdoc}
*/
public function save(array $form, FormStateInterface $form_state)
{
parent::save($form, $form_state);
$payment_method_configuration = $this->getEntity();
drupal_set_message($this->t('@label has been saved.', array('@label' => $payment_method_configuration->label())));
$form_state->setRedirectUrl($payment_method_configuration->urlInfo('collection'));
}
示例7: save
/**
* {@inheritdoc}
*/
public function save(array $form, FormStateInterface $form_state)
{
$status = parent::save($form, $form_state);
if ($status) {
drupal_set_message($this->t('Saved the %label variant.', ['%label' => $this->entity->label()]));
} else {
drupal_set_message($this->t('The %label variant was not saved.', ['%label' => $this->entity->label()]));
}
}