isSuccess on forms from new instance
- AndiLeni
- Member | 8
Hello,
is it possible to check isSuccess() on a form which was created in a new instance?
I am using Nette\Forms in another application wiht the FatfreeFramework.
In my current implementation isSuccess() is always false, since I have different route handlers for GET and POST request and I create the form on each one.
$f3->route(
'GET @add: /add/@table',
function ($f3) {
...
// this calls 'new Form'
$form = new \FormGenerator($form_schema, "/add/$table");
...
}
);
$f3->route(
'POST /add/@table',
function ($f3) {
...
// create form with same parameters, but again with 'new Form'
$form_generator = new \FormGenerator($form_schema, "/add/$table");
// is always false
dump($form->isSuccess());
// values are correct
dump($form->getValues($returnType = 'array'));
...
}
);
Is this somehow possible, or should I simply ommit isSuccess()?
Thanks and kind regards
- petr.pavel
- Member | 533
Do you have any validators attached to the form items/form itself? Could it
be that the form is submitted but not valid? Try output of
isSubmitted()
and isValid()
separately.
- petr.pavel
- Member | 533
Well, if isValid()
returns false then isSuccess()
cannot return true. Dump $form->getErrors()
to see why
it's not valid.