本文整理汇总了PHP中Drupal\Core\Entity\ContentEntityForm::submit方法的典型用法代码示例。如果您正苦于以下问题:PHP ContentEntityForm::submit方法的具体用法?PHP ContentEntityForm::submit怎么用?PHP ContentEntityForm::submit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Entity\ContentEntityForm
的用法示例。
在下文中一共展示了ContentEntityForm::submit方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: submit
/**
* Overrides \Drupal\Core\Entity\EntityFormController::submit().
*/
public function submit(array $form, array &$form_state)
{
// Build the entity object from the submitted values.
$entity = parent::submit($form, $form_state);
$form_state['redirect_route']['route_name'] = 'foo_bar.list';
return $entity;
}
示例2: submit
/**
* Overrides \Drupal\Core\Entity\EntityForm::submit().
*/
public function submit(array $form, array &$form_state)
{
// Build the entity object from the submitted values.
$entity = parent::submit($form, $form_state);
// Save as a new revision if requested to do so.
if (!empty($form_state['values']['revision'])) {
$entity->setNewRevision();
}
return $entity;
}
示例3: submit
/**
* {@inheritdoc}
*/
public function submit(array $form, FormStateInterface $form_state) {
// Build the entity object from the submitted values.
$entity = parent::submit($form, $form_state);
return $entity;
}
示例4: submitConfigurationForm
/**
* {@inheritdoc}
*/
public function submitConfigurationForm(array &$form, FormStateInterface $form_state)
{
// Remove button and internal Form API values from submitted values.
parent::submit($form, $form_state);
$this->save($form, $form_state);
}
示例5: submit
/**
* {@inheritdoc}
*/
public function submit(array $form, FormStateInterface $form_state)
{
parent::submit($form, $form_state);
$user = $this->getEntity($form_state);
// If there's a session set to the users id, remove the password reset tag
// since a new password was saved.
if (isset($_SESSION['pass_reset_' . $user->id()])) {
unset($_SESSION['pass_reset_' . $user->id()]);
}
}
示例6: submit
/**
* Overrides Drupal\Core\Entity\EntityForm::submit().
*/
public function submit(array $form, array &$form_state)
{
/** @var \Drupal\comment\CommentInterface $comment */
$comment = parent::submit($form, $form_state);
// If the comment was posted by a registered user, assign the author's ID.
// @todo Too fragile. Should be prepared and stored in comment_form()
// already.
$author_name = $comment->getAuthorName();
if (!$comment->is_anonymous && !empty($author_name) && ($account = user_load_by_name($author_name))) {
$comment->setOwner($account);
}
// If the comment was posted by an anonymous user and no author name was
// required, use "Anonymous" by default.
if ($comment->is_anonymous && (!isset($author_name) || $author_name === '')) {
$comment->setAuthorName($this->config('user.settings')->get('anonymous'));
}
// Validate the comment's subject. If not specified, extract from comment
// body.
if (trim($comment->getSubject()) == '') {
// The body may be in any format, so:
// 1) Filter it into HTML
// 2) Strip out all HTML tags
// 3) Convert entities back to plain-text.
$comment_text = $comment->comment_body->processed;
$comment->setSubject(Unicode::truncate(trim(String::decodeEntities(strip_tags($comment_text))), 29, TRUE));
// Edge cases where the comment body is populated only by HTML tags will
// require a default subject.
if ($comment->getSubject() == '') {
$comment->setSubject($this->t('(No subject)'));
}
}
return $comment;
}
示例7: submit
/**
* Updates the node object by processing the submitted values.
*
* This function can be called by a "Next" button of a wizard to update the
* form state's entity with the current step's values before proceeding to the
* next step.
*
* Overrides Drupal\Core\Entity\EntityForm::submit().
*/
public function submit(array $form, array &$form_state)
{
// Build the node object from the submitted values.
$node = parent::submit($form, $form_state);
// Save as a new revision if requested to do so.
if (!empty($form_state['values']['revision']) && $form_state['values']['revision'] != FALSE) {
$node->setNewRevision();
// If a new revision is created, save the current user as revision author.
$node->setRevisionCreationTime(REQUEST_TIME);
$node->setRevisionAuthorId(\Drupal::currentUser()->id());
} else {
$node->setNewRevision(FALSE);
}
$node->validated = TRUE;
foreach (\Drupal::moduleHandler()->getImplementations('node_submit') as $module) {
$function = $module . '_node_submit';
$function($node, $form, $form_state);
}
return $node;
}
示例8: submit
/**
* Overrides \Drupal\Core\Entity\EntityForm::submit().
*
* Updates the custom block object by processing the submitted values.
*
* This function can be called by a "Next" button of a wizard to update the
* form state's entity with the current step's values before proceeding to the
* next step.
*/
public function submit(array $form, FormStateInterface $form_state)
{
// Build the block object from the submitted values.
$block = parent::submit($form, $form_state);
// Save as a new revision if requested to do so.
if (!empty($form_state['values']['revision'])) {
$block->setNewRevision();
}
return $block;
}