Closed harikt closed 9 years ago
I like this suggestion and I'm willing to work on this if you both don't have the time.
I think that isSuccess()
should throw an exception when filter()
has not been called.
I would also like to suggest that fill()
return $this
so that it can be chained with filter:
$form->fill($data)->filter();
if ($form->isSuccess() === true) {
Cheers Stephen
I'm OK with fill() being fluent.
I'm also OK with an isSuccess(), though I'd like for it to be ternary (true/false, and null if filter has not been called).
I don't recall -- do we have an isFailure() method?
I'm wondering why isSuccess()
should return null
if filter()
hasn't been called? I feel like isSuccess()
should not be called unless filter()
has been called, and thus, should throw an exception.
$form->fill($data);
if ($form->isSuccess()) { // Throw exception
By throwing an exception, your telling the developer that they have missed something. Otherwise the developer could write code for an unknown state.
if ($form->isSuccess()) {
// Save Data
} else {
// Are we false or null? Should I check?
}
Would love to hear your thoughts.
There is no isFailure()
method().
@stephen-hill I don't think I will be able to look into this for the current time.
Feel free to pickup and move forward.
Thank you.
@stephen-hill seems to have finished this off.
@pmjones Thanks for merging this addition.
Hi Paul,
I was working on form, and submissions lately with the ADR .
The form is injected to the Domain\Contact . Now when the request method is post the form is calling
fill()
andfilter()
.We are setting the form back to the responder.
One thing probably you may mention will be keep the get and post Actions different. But to me it seems duplicating so much efforts.
I was thinking whether it is good to have a
isSuccess()
method and return true / false if a check onfilter()
is called. Else nothing is returned.Another thing is
getMessages()
can be checked for errors, but if the form is not submitted thegetMessages()
empty and that doesn't means it is success and display the message, the wayisSuccess
help us is recognize whether a call to filter has happened rather the user testing again on responder with certain flags set when a request is submitted etc.Interested to hear your thoughts.
Thank you