Manually submit form in presenter #2

Notice: This thread is very old.
Generous Backer | 680


I need form, that user can fill and send. And at the same time, I need form, which application can prefill automatically (using setDefaults method) and send programmatically. Why? Because validation – if there will be error in prefilled data, validation fails and user will have to fix data in form manually.

I can't find any suitable solution. It's almost same question as this…in-presenter, but it hasn't solved.

Any ideas?

Member | 58

Hi, you don't need to submit the form to check if is valid. Set (default) values and then simply validate the form.

$form = $this->getComponent('myForm');


if ($form->isValid()) {

	... show message, redirect, etc.

} else {

... show the form so user can fix incorrect values, etc.
Member | 17


I don't understand why you should set incorrect default values. If they are loaded e.g. from the database, they should have either be validated before saved in there or corrected when filling the form with them using setDefaults(). If that is not what you want to do, sorry, I might have misunderstood your question.

I also don't understand what is the problem when calling setDefaults(). Do you want to have the form twice in the same time on your page?

Honza Kuchař
Backer | 1656

This is bad design.

You have to send form using JavaScript.

Or you can validate your data on server-side using Validators from forms.…alidator.php#L86