Get the posted data from Form in Zend Framework 2

后端 未结 2 825
生来不讨喜
生来不讨喜 2021-01-18 06:40

Im new to Zend Framework, so asking a basic question. I want to get the posted data, in general from one field in a form, I wanted to get the data for debugging purposes.

2条回答
  •  心在旅途
    2021-01-18 07:18

    You're not very clear so I suggets a few solutions...

    If you need the plain POST value, you can access it using

    $this->getRequest()->getPost('name');
    

    From the controller's context.

    If you need the value from the form which has been assigned previously, you can access it using

    $form->get('elementName')->getValue();
    

    However, if you're using InputFilters, you need to fetch it using

    $form->getInputFilter()->getValue('name');
    

    Otherwise, the value you're retrieving was not passed through the filters.

提交回复
热议问题