isSuccess on forms from new instance

AndiLeni
Member | 8
+
0
-

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 | 531
+
0
-

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.

AndiLeni
Member | 8
+
0
-

@petr.pavel

No, I do not have any validators.

This is what I tried with your suggestion:

dump($form->isSuccess()) //false;
dump($form->isSubmitted()) //Nette\Forms\Controls\SubmitButton;
dump($form->isValid()) //false;
petr.pavel
Member | 531
+
+3
-

Well, if isValid() returns false then isSuccess() cannot return true. Dump $form->getErrors() to see why it's not valid.

AndiLeni
Member | 8
+
0
-

@petrpavel thank you very much!
This did indeed help me. I had an email field which contained an address like "abc@def" which is valid for the in-browser validator but nette seems to be more restrictive.