8000 [Form] Introduced proxy methods to allow easier handling of form errors by zebba · Pull Request #29521 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Form] Introduced proxy methods to allow easier handling of form errors #29521

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/Symfony/Component/Form/Button.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,22 @@ public function getErrors($deep = false, $flatten = true)
return new FormErrorIterator($this, array());
}

/**
* {@inheritdoc}
*/
public function getAllErrors()
{
return $this->getErrors();
}

/**
* {@inheritdoc}
*/
public function getOnlyGlobalErrors()
{
return $this->getErrors();
}

/**
* Unsupported method.
*
Expand Down
16 changes: 16 additions & 0 deletions src/Symfony/Component/Form/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,22 @@ public function getErrors($deep = false, $flatten = true)
return new FormErrorIterator($this, $errors);
}

/**
* {@inheritdoc}
*/
public function getAllErrors()
{
return $this->getErrors(true);
}

/**
* {@inheritdoc}
*/
public function getOnlyGlobalErrors()
{
return $this->getErrors();
}

/**
* {@inheritdoc}
*
Expand Down
18 changes: 18 additions & 0 deletions src/Symfony/Component/Form/FormInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,24 @@ public function all();
*/
public function getErrors($deep = false, $flatten = true);

/**
* Returns the list of the current form and all child forms.
*
* @return FormErrorIterator An iterator over the {@link FormError}
* instances that where added to the form
* and the child forms
*/
public function getAllErrors();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot change the interface until Symfony 5.0 for BC.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually totally forgot about that part and agree. I've changed the description.


/**
* Returns the list of this form only - without child errors.
*
* @return FormErrorIterator An iterator over the {@link FormError}
* instances that where added to the top
* level of this form
*/
public function getOnlyGlobalErrors();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name sounds confusing for a form which is not the root.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to stick with the naming in the current documentation:

// a FormErrorIterator instance, but only errors attached to this
// form level (e.g. global errors)

But getRootErrors() works for me too if this is a naming we can agree on? The suggested getOwnErrors() didn't appeal to me.


/**
* Updates the form with default data.
*
Expand Down
0