Commit b4b94c02 authored by alexpott's avatar alexpott

Revert "Issue #2459753 follow-up by tim.plunkett, alexpott:...

Revert "Issue #2459753 follow-up by tim.plunkett, alexpott: EntityForm::validate() should be able to modify the form structure"

This reverts commit fb5ea78b.
parent fb5ea78b
...@@ -121,7 +121,7 @@ public function delete(array $form, FormStateInterface $form_state) {} ...@@ -121,7 +121,7 @@ public function delete(array $form, FormStateInterface $form_state) {}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function validate(array &$form, FormStateInterface $form_state) { public function validate(array $form, FormStateInterface $form_state) {
// Override the default validation implementation as it is not necessary // Override the default validation implementation as it is not necessary
// nor possible to validate an entity in a confirmation form. // nor possible to validate an entity in a confirmation form.
} }
......
...@@ -74,7 +74,7 @@ public function form(array $form, FormStateInterface $form_state) { ...@@ -74,7 +74,7 @@ public function form(array $form, FormStateInterface $form_state) {
* For more information about entity validation, see * For more information about entity validation, see
* https://www.drupal.org/node/2015613. * https://www.drupal.org/node/2015613.
*/ */
public function validate(array &$form, FormStateInterface $form_state) { public function validate(array $form, FormStateInterface $form_state) {
$entity = $this->buildEntity($form, $form_state); $entity = $this->buildEntity($form, $form_state);
$this->getFormDisplay($form_state)->validateFormValues($entity, $form, $form_state); $this->getFormDisplay($form_state)->validateFormValues($entity, $form, $form_state);
......
...@@ -247,7 +247,7 @@ protected function actions(array $form, FormStateInterface $form_state) { ...@@ -247,7 +247,7 @@ protected function actions(array $form, FormStateInterface $form_state) {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function validate(array &$form, FormStateInterface $form_state) { public function validate(array $form, FormStateInterface $form_state) {
// @todo Remove this. // @todo Remove this.
// Execute legacy global validation handlers. // Execute legacy global validation handlers.
$form_state->setValidateHandlers([]); $form_state->setValidateHandlers([]);
......
...@@ -105,7 +105,7 @@ public function buildEntity(array $form, FormStateInterface $form_state); ...@@ -105,7 +105,7 @@ public function buildEntity(array $form, FormStateInterface $form_state);
* @return \Drupal\Core\Entity\ContentEntityTypeInterface * @return \Drupal\Core\Entity\ContentEntityTypeInterface
* The built entity. * The built entity.
*/ */
public function validate(array &$form, FormStateInterface $form_state); public function validate(array $form, FormStateInterface $form_state);
/** /**
* Form submission handler for the 'save' action. * Form submission handler for the 'save' action.
......
...@@ -123,7 +123,7 @@ protected function actions(array $form, FormStateInterface $form_state) { ...@@ -123,7 +123,7 @@ protected function actions(array $form, FormStateInterface $form_state) {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function validate(array &$form, FormStateInterface $form_state) { public function validate(array $form, FormStateInterface $form_state) {
parent::validate($form, $form_state); parent::validate($form, $form_state);
if ($this->plugin instanceof PluginFormInterface) { if ($this->plugin instanceof PluginFormInterface) {
......
...@@ -273,7 +273,7 @@ protected function actions(array $form, FormStateInterface $form_state) { ...@@ -273,7 +273,7 @@ protected function actions(array $form, FormStateInterface $form_state) {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function validate(array &$form, FormStateInterface $form_state) { public function validate(array $form, FormStateInterface $form_state) {
parent::validate($form, $form_state); parent::validate($form, $form_state);
// The Block Entity form puts all block plugin form elements in the // The Block Entity form puts all block plugin form elements in the
......
...@@ -223,7 +223,7 @@ public function save(array $form, FormStateInterface $form_state) { ...@@ -223,7 +223,7 @@ public function save(array $form, FormStateInterface $form_state) {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function validate(array &$form, FormStateInterface $form_state) { public function validateForm(array &$form, FormStateInterface $form_state) {
if ($this->entity->isNew()) { if ($this->entity->isNew()) {
$exists = $this->blockContentStorage->loadByProperties(array('info' => $form_state->getValue(['info', 0, 'value']))); $exists = $this->blockContentStorage->loadByProperties(array('info' => $form_state->getValue(['info', 0, 'value'])));
if (!empty($exists)) { if (!empty($exists)) {
......
...@@ -314,7 +314,7 @@ public function buildEntity(array $form, FormStateInterface $form_state) { ...@@ -314,7 +314,7 @@ public function buildEntity(array $form, FormStateInterface $form_state) {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function validate(array &$form, FormStateInterface $form_state) { public function validate(array $form, FormStateInterface $form_state) {
$comment = parent::validate($form, $form_state); $comment = parent::validate($form, $form_state);
// Customly trigger validation of manually added fields and add in // Customly trigger validation of manually added fields and add in
......
...@@ -112,7 +112,7 @@ public function form(array $form, FormStateInterface $form_state) { ...@@ -112,7 +112,7 @@ public function form(array $form, FormStateInterface $form_state) {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function validate(array &$form, FormStateInterface $form_state) { public function validate(array $form, FormStateInterface $form_state) {
parent::validate($form, $form_state); parent::validate($form, $form_state);
// Validate and each email recipient. // Validate and each email recipient.
......
...@@ -187,7 +187,7 @@ public function preview(array $form, FormStateInterface $form_state) { ...@@ -187,7 +187,7 @@ public function preview(array $form, FormStateInterface $form_state) {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function validate(array &$form, FormStateInterface $form_state) { public function validate(array $form, FormStateInterface $form_state) {
parent::validate($form, $form_state); parent::validate($form, $form_state);
$message = $this->entity; $message = $this->entity;
......
...@@ -38,7 +38,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $entity_t ...@@ -38,7 +38,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $entity_t
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function validate(array &$form, FormStateInterface $form_state) { public function validate(array $form, FormStateInterface $form_state) {
parent::validate($form, $form_state); parent::validate($form, $form_state);
$form_state->setValueForElement($form['id'], $this->targetEntityTypeId . '.' . $form_state->getValue('id')); $form_state->setValueForElement($form['id'], $this->targetEntityTypeId . '.' . $form_state->getValue('id'));
......
...@@ -150,7 +150,7 @@ protected function actions(array $form, FormStateInterface $form_state) { ...@@ -150,7 +150,7 @@ protected function actions(array $form, FormStateInterface $form_state) {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function validate(array &$form, FormStateInterface $form_state) { public function validate(array $form, FormStateInterface $form_state) {
parent::validate($form, $form_state); parent::validate($form, $form_state);
if (isset($form['default_value'])) { if (isset($form['default_value'])) {
......
...@@ -146,7 +146,7 @@ protected function actions(array $form, FormStateInterface $form_state) { ...@@ -146,7 +146,7 @@ protected function actions(array $form, FormStateInterface $form_state) {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function validate(array &$form, FormStateInterface $form_state) { public function validate(array $form, FormStateInterface $form_state) {
parent::validate($form, $form_state); parent::validate($form, $form_state);
// Validate field cardinality. // Validate field cardinality.
......
...@@ -204,7 +204,7 @@ public function exists($format_id) { ...@@ -204,7 +204,7 @@ public function exists($format_id) {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function validate(array &$form, FormStateInterface $form_state) { public function validate(array $form, FormStateInterface $form_state) {
parent::validate($form, $form_state); parent::validate($form, $form_state);
// @todo Move trimming upstream. // @todo Move trimming upstream.
......
...@@ -286,7 +286,7 @@ protected function actions(array $form, FormStateInterface $form_state) { ...@@ -286,7 +286,7 @@ protected function actions(array $form, FormStateInterface $form_state) {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function validate(array &$form, FormStateInterface $form_state) { public function validate(array $form, FormStateInterface $form_state) {
$node = parent::validate($form, $form_state); $node = parent::validate($form, $form_state);
if ($node->id() && (node_last_changed($node->id(), $this->getFormLangcode($form_state)) > $node->getChangedTime())) { if ($node->id() && (node_last_changed($node->id(), $this->getFormLangcode($form_state)) > $node->getChangedTime())) {
......
...@@ -204,7 +204,7 @@ protected function actions(array $form, FormStateInterface $form_state) { ...@@ -204,7 +204,7 @@ protected function actions(array $form, FormStateInterface $form_state) {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function validate(array &$form, FormStateInterface $form_state) { public function validate(array $form, FormStateInterface $form_state) {
parent::validate($form, $form_state); parent::validate($form, $form_state);
$id = trim($form_state->getValue('type')); $id = trim($form_state->getValue('type'));
......
...@@ -133,7 +133,7 @@ public function form(array $form, FormStateInterface $form_state) { ...@@ -133,7 +133,7 @@ public function form(array $form, FormStateInterface $form_state) {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function validate(array &$form, FormStateInterface $form_state) { public function validate(array $form, FormStateInterface $form_state) {
// Only validate on edit. // Only validate on edit.
if ($form_state->hasValue('keyed_styles')) { if ($form_state->hasValue('keyed_styles')) {
// Check if another breakpoint group is selected. // Check if another breakpoint group is selected.
......
...@@ -144,7 +144,7 @@ public function exists($id) { ...@@ -144,7 +144,7 @@ public function exists($id) {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function validate(array &$form, FormStateInterface $form_state) { public function validate(array $form, FormStateInterface $form_state) {
parent::validate($form, $form_state); parent::validate($form, $form_state);
// Ensure each path is unique. // Ensure each path is unique.
......
...@@ -155,7 +155,7 @@ public function form(array $form, FormStateInterface $form_state) { ...@@ -155,7 +155,7 @@ public function form(array $form, FormStateInterface $form_state) {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function validate(array &$form, FormStateInterface $form_state) { public function validate(array $form, FormStateInterface $form_state) {
parent::validate($form, $form_state); parent::validate($form, $form_state);
// The machine name field should already check to see if the requested // The machine name field should already check to see if the requested
......
...@@ -94,7 +94,7 @@ public function form(array $form, FormStateInterface $form_state) { ...@@ -94,7 +94,7 @@ public function form(array $form, FormStateInterface $form_state) {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function validate(array &$form, FormStateInterface $form_state) { public function validate(array $form, FormStateInterface $form_state) {
parent::validate($form, $form_state); parent::validate($form, $form_state);
// Ensure numeric values. // Ensure numeric values.
......
...@@ -354,7 +354,7 @@ public function buildEntity(array $form, FormStateInterface $form_state) { ...@@ -354,7 +354,7 @@ public function buildEntity(array $form, FormStateInterface $form_state) {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function validate(array &$form, FormStateInterface $form_state) { public function validate(array $form, FormStateInterface $form_state) {
/** @var \Drupal\user\UserInterface $account */ /** @var \Drupal\user\UserInterface $account */
$account = parent::validate($form, $form_state); $account = parent::validate($form, $form_state);
......
...@@ -162,7 +162,7 @@ protected function actions(array $form, FormStateInterface $form_state) { ...@@ -162,7 +162,7 @@ protected function actions(array $form, FormStateInterface $form_state) {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function validate(array &$form, FormStateInterface $form_state) { public function validate(array $form, FormStateInterface $form_state) {
$wizard_type = $form_state->getValue(array('show', 'wizard_key')); $wizard_type = $form_state->getValue(array('show', 'wizard_key'));
$wizard_instance = $this->wizardManager->createInstance($wizard_type); $wizard_instance = $this->wizardManager->createInstance($wizard_type);
$form_state->set('wizard', $wizard_instance->getPluginDefinition()); $form_state->set('wizard', $wizard_instance->getPluginDefinition());
......
...@@ -258,7 +258,7 @@ protected function actions(array $form, FormStateInterface $form_state) { ...@@ -258,7 +258,7 @@ protected function actions(array $form, FormStateInterface $form_state) {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function validate(array &$form, FormStateInterface $form_state) { public function validate(array $form, FormStateInterface $form_state) {
parent::validate($form, $form_state); parent::validate($form, $form_state);
$view = $this->entity; $view = $this->entity;
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
use Drupal\Core\Entity\EntityForm; use Drupal\Core\Entity\EntityForm;
use Drupal\Core\Form\FormState; use Drupal\Core\Form\FormState;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Tests\UnitTestCase; use Drupal\Tests\UnitTestCase;
/** /**
...@@ -124,20 +123,4 @@ public function testCopyFormValuesToEntity() { ...@@ -124,20 +123,4 @@ public function testCopyFormValuesToEntity() {
$this->assertNull($result->get('key_controlled_by_plugin_collection')); $this->assertNull($result->get('key_controlled_by_plugin_collection'));
} }
/**
* @covers ::validate
*/
public function testValidate() {
$form_object = $this->getMock('Drupal\Core\Entity\EntityFormInterface');
$form_object->expects($this->once())
->method('validate')
->willReturnCallback(function (array &$form, FormStateInterface $form_state) {
$form['foo'] = 'bar';
});
$form['baz'] = 'bim';
$form_state = new FormState();
$form_object->validate($form, $form_state);
$this->assertArrayHasKey('foo', $form);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment