本文整理汇总了PHP中Drupal\Core\Entity\ContentEntityForm::save方法的典型用法代码示例。如果您正苦于以下问题:PHP ContentEntityForm::save方法的具体用法?PHP ContentEntityForm::save怎么用?PHP ContentEntityForm::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Entity\ContentEntityForm
的用法示例。
在下文中一共展示了ContentEntityForm::save方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveDraft
public function saveDraft(array $form, FormStateInterface $form_state) {
/** @var \Drupal\eform\Entity\EFormSubmission $entity */
$entity = $this->entity;
$entity->setDraft(EFORM_DRAFT);
return parent::save($form, $form_state);
}
示例2: 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);
}
示例3: save
/**
* {@inheritdoc}
*/
public function save(array $form, FormStateInterface $form_state)
{
$entity = $this->entity;
$status = parent::save($form, $form_state);
switch ($status) {
case SAVED_NEW:
drupal_set_message($this->t('Created the %label Component.', ['%label' => $entity->label()]));
break;
default:
drupal_set_message($this->t('Saved the %label Component.', ['%label' => $entity->label()]));
}
$form_state->setRedirect('entity.component.canonical', ['component' => $entity->id()]);
}
示例4: save
/**
* {@inheritdoc}
*/
public function save(array $form, FormStateInterface $form_state)
{
parent::save($form, $form_state);
/** @var LocalTaskItem $task_item */
$task_item = $this->entity;
$form_state->cleanValues();
foreach ($form_state->getValues() as $key => $value) {
if (is_array($value) && isset($value['translation'])) {
// Update the translation, this will only update the translation in case
// it has changed. We have two different cases, the first is for nested
// texts.
if (is_array($value['translation'])) {
$update['#translation']['#text'] = $value['translation']['value'];
} else {
$update['#translation']['#text'] = $value['translation'];
}
$task_item->updateData($key, $update);
}
}
$task_item->save();
if ($form_state->getTriggeringElement()['#value'] == $form['actions']['save']['#value']) {
drupal_set_message(t('The translation for <a href=:task_item>@task_item_title</a> has been saved.', [':task_item' => $task_item->urlInfo()->toString(), '@task_item_title' => $task_item->label()]));
}
$task = $task_item->getTask();
$uri = $task->urlInfo();
$form_state->setRedirect($uri->getRouteName(), $uri->getRouteParameters());
}
示例5: save
/**
* {@inheritDoc}
*/
public function save(array $form, FormStateInterface $form_state)
{
parent::save($form, $form_state);
// Redirect to stored entry.
$form_state->setRedirect('entity.mollom_test_post.edit_form', array('mollom_test_post' => $this->entity->id()));
}