本文整理匯總了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()));
}