A
A
Andrew2016-01-07 04:33:30
Zend Framework
Andrew, 2016-01-07 04:33:30

Zend Framework 1. How to keep entered values ​​after form reload?

There is a form class:

class Application_Form_Sort extends Zend_Form
{

    public function init()
    {
        $this->setMethod('GET');

        $this->addElement('select', 'sortby',
            array(
                'label' => 'Сортировать по',
                'multiOptions' =>
                    array(
                        'message_id' => 'Номеру',
                        'title' => 'Заголовку',
                        'created_at' => 'Дате публикации',
                    ),
            )
        );

        $this->addElement('select', 'orderby', array(
            'label' => 'Порядок', 'value' => 'ASC',
            'multiOptions' => array('ASC' => 'Прямой', 'DESC' => 'Обратный',),));

        $this->addElement('submit', 'sort', array(
            'ignore' => true,
            'label' => 'Сортировать',
        ));
    }

}

I get it through the controller and define it in the view:
$sort = new Application_Form_Sort();
$this->view->sort = $sort;

I'll clarify that the data is sent via GET (I'm trying to sort it this way).
When I select values ​​in the select sheet and submit the form, after submitting the form returns to its original value, but I would like it to remember the last submission, or at least take data from the GET parameter.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vit, 2016-01-07
@ntzch

the form's populate method must be called if memory serves. There it is necessary to transfer data from requests, then the values ​​​​will be set in the form.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question