To create our first registration form, we will create a new controller to display a registration form; we will also create new forms and views. We need to make the following changes to the Users
module:
Form – We will also need to create a registration form under
src/Users/Form/RegisterForm.php
:The
RegisterForm
class extendsZend\Form\Form
; the form's configuration is added to the constructor:<?php // filename : module/Users/src/Users/Form/RegisterForm.php namespace Users\Form; use Zend\Form\Form; class RegisterForm extends Form { public function __construct($name = null) { parent::__construct('Register'); $this->setAttribute('method', 'post'); $this->setAttribute('enctype','multipart/form-data');
All fields are added to the form using the
$this->add()
method on the form's constructor:$this->add(array( 'name' => 'name', 'attributes' => array( ...