use Zend\Form\Form; $form = new Form(); $form->add([ 'name' => 'username', 'type' => 'Text', 'options' => [ 'label' => 'Username', ], ]); if ($this->getRequest()->isPost()) { $form->setData($this->getRequest()->getPost()); if ($form->isValid()) { $username = $form->get('username')->getValue(); // process data } }
if ($this->getRequest()->isPost()) { $form->setData($this->getRequest()->getPost()); if ($form->isValid()) { $data = $form->getData(); // process data } }In this example, we again set the submitted data and check if the form is valid. However, instead of retrieving a single field value, we use `getData()` to retrieve an array of all submitted form data. The package library for this component is `zendframework/zend-form`.