How I can remove element form or validator?
|
Dec '14 |
6 |
2174 |
2 |
I have a complex form, which on certain conditions may vary. Some fields are removed, some validators change. And at the moment, for me, this object is very difficult. Even if I just do not make any unnecessary items, in the Temple I can not verify their existence, to know which block to bring and what not.
I wanted to do, by analogy with Zend. To make the form and bring it through the echo $ form->render(), and then depending on the delete some items. But now I realized that I needed something to do with the template, because to remove items from the form is not enough, you also need to not try to take them in template.
I still do not understand how to do. Let's say I need in some cases to turn off specific validators. I have a code like this: public function indexAction () { $model = new \Model(); $form = $model->getForm();//return Phalcon\Forms\Form if($this->request->isPost()){ if($form->isValid($_POST)){ $model->save(); } else { var_dump($form->getMessages());die; } } }
My form has a validator, and the model, no, I was validating data form and it is in it I need to disable the validators, so replacement method getMessages (), the model does not help me. Maybe I was not the correct action?
So as I see, functionality to remove element from form is added. But at this moment I need to remove some validators from element. And I think this question is still open. So is it possible to remove validator from form element?