Open
Description
Description
I think for developer experience it would be nice if there would be a method which is doing handleRequest and returning the valid state in one method.
Example
Most form controller looks like this:
$form = $this->formFactory->create(...);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
// Do something
}
I think it would be better for DX to have something like:
$form = $this->formFactory->create(...);
if ($form->handleRequestAndValid($request)) {
// Do something
}
Another possibility would be change the handleRequest
to match more this common usage, currently via a BC layer example like:
$form = $this->formFactory->create(...);
if ($form->handleRequest($request, validate: true)) {
// Do something
}
Update
After some discussion in the comment I think best would be:
$form = $this->formFactory->create(...);
if ($form->handleRequest($request)->isSubmittedAndIsValid()) {
// Do something
}