Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
0b5f5ce8
Commit
0b5f5ce8
authored
Feb 28, 2015
by
alexpott
Browse files
Issue
#1768526
by swentel, Berdir: NodeFormController::validate() calls buildEntity() twice
parent
4f33bd49
Changes
5
Hide whitespace changes
Inline
Side-by-side
core/lib/Drupal/Core/Entity/ContentEntityForm.php
View file @
0b5f5ce8
...
...
@@ -76,6 +76,7 @@ public function validate(array $form, FormStateInterface $form_state) {
// Execute legacy global validation handlers.
$form_state
->
setValidateHandlers
([]);
\
Drupal
::
service
(
'form_validator'
)
->
executeValidateHandlers
(
$form
,
$form_state
);
return
$entity
;
}
/**
...
...
core/lib/Drupal/Core/Entity/EntityFormInterface.php
View file @
0b5f5ce8
...
...
@@ -101,6 +101,9 @@ public function buildEntity(array $form, FormStateInterface $form_state);
* A nested array form elements comprising the form.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current state of the form.
*
* @return \Drupal\Core\Entity\ContentEntityTypeInterface
* The built entity.
*/
public
function
validate
(
array
$form
,
FormStateInterface
$form_state
);
...
...
core/modules/comment/src/CommentForm.php
View file @
0b5f5ce8
...
...
@@ -287,8 +287,7 @@ public function buildEntity(array $form, FormStateInterface $form_state) {
* {@inheritdoc}
*/
public
function
validate
(
array
$form
,
FormStateInterface
$form_state
)
{
parent
::
validate
(
$form
,
$form_state
);
$comment
=
$this
->
buildEntity
(
$form
,
$form_state
);
$comment
=
parent
::
validate
(
$form
,
$form_state
);
// Customly trigger validation of manually added fields and add in
// violations.
...
...
@@ -300,6 +299,8 @@ public function validate(array $form, FormStateInterface $form_state) {
foreach
(
$violations
as
$violation
)
{
$form_state
->
setErrorByName
(
'name'
,
$violation
->
getMessage
());
}
return
$comment
;
}
/**
...
...
core/modules/node/src/NodeForm.php
View file @
0b5f5ce8
...
...
@@ -292,13 +292,13 @@ protected function actions(array $form, FormStateInterface $form_state) {
* {@inheritdoc}
*/
public
function
validate
(
array
$form
,
FormStateInterface
$form_state
)
{
$node
=
$this
->
buildEntity
(
$form
,
$form_state
);
$node
=
parent
::
validate
(
$form
,
$form_state
);
if
(
$node
->
id
()
&&
(
node_last_changed
(
$node
->
id
(),
$this
->
getFormLangcode
(
$form_state
))
>
$node
->
getChangedTime
()))
{
$form_state
->
setErrorByName
(
'changed'
,
$this
->
t
(
'The content on this page has either been modified by another user, or you have already submitted modifications using this form. As a result, your changes cannot be saved.'
));
}
parent
::
validate
(
$form
,
$form_state
)
;
return
$node
;
}
/**
...
...
core/modules/user/src/AccountForm.php
View file @
0b5f5ce8
...
...
@@ -383,10 +383,9 @@ public function buildEntity(array $form, FormStateInterface $form_state) {
* {@inheritdoc}
*/
public
function
validate
(
array
$form
,
FormStateInterface
$form_state
)
{
parent
::
validate
(
$form
,
$form_state
);
/** @var \Drupal\user\UserInterface $account */
$account
=
$this
->
buildEntity
(
$form
,
$form_state
);
$account
=
parent
::
validate
(
$form
,
$form_state
);
// Customly trigger validation of manually added fields and add in
// violations. This is necessary as entity form displays only invoke entity
// validation for fields contained in the display.
...
...
@@ -406,6 +405,8 @@ public function validate(array $form, FormStateInterface $form_state) {
$form_state
->
setErrorByName
(
$field_name
,
$violation
->
getMessage
());
}
}
return
$account
;
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment