A
A
Andrew2016-07-07 17:48:30
Zend Framework
Andrew, 2016-07-07 17:48:30

Zend Framework 1: Why doesn't $form->isValid work with $field->->setBelongsTo('art');?

Hello. I make a shape, divided it into several parts (what would be in subarrays) using $field->->setBelongsTo('art');. This is how the code for one field looks in full:

//Заголовок новости
        $news_title = new Zend_Form_Element_Text('title');
        $news_title->setBelongsTo('news');
        $news_title->setRequired(true);
        $news_title->setLabel('Тема:');
        $news_title->setDecorators(
            $this->Decorator('required')
        );
        $news_title->addFilter(new Zend_Filter_StringTrim());
        $news_title->addFilter(new Zend_Filter_StripTags());
        $this->addElement($news_title);

Along with this part, I have a few more with other arrays in setBelongsTo.
The problem is that in the controller this code does not pass as valid when all the data is filled in, that is, it does not fall into this condition:
if($request->isPost() && $news_form->isValid($request->getParam('news'))){
            
        }

In $request->getParams(); the data is empty and there is only a one-dimensional array, I don’t know if it should be like this ... If you remove setBelongsTo, then everything goes well, but how to make the form validation work with this parameter?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question