title: Extending ZfcUser with Zend Framework 2
body: <p>Hi I am trying to write a user registration form using ZfcUser module for Zend Framwork 2 and would like some advice on best practices when adding more user fields.</p>
  
  <p>So far I have created my own module called "WbxUser" and as outlined in the <a href="https://github.com/ZF-Commons/ZfcUser/wiki/How-to-modify-the-form-objects-used-by-ZfcUser">modules wiki pages</a>   I have added a custom field called "userlastname" to ZfcUser's registration form by using the Event Manager in my modules bootstrap function like so.</p>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>//WbxUser.Module.php   
  
  namespace WbxUser;
  
  use Zend\Mvc\MvcEvent;
  
  
  class Module {
      public function onBootstrap(MvcEvent $e){
          $events = $e-&gt;getApplication()-&gt;getEventManager()-&gt;getSharedManager();
          $events-&gt;attach('ZfcUser\Form\Register','init', function($e) {
              $form = $e-&gt;getTarget();
              $form-&gt;add(array(
                      'name' =&gt; 'userlastname',
                      'attributes' =&gt; array(
                              'type'  =&gt; 'text',
                      ),
                      'options' =&gt; array(
                              'label' =&gt; 'Last Name',
                      ),
              ));
              // Do what you please with the form instance ($form)
          });
  
          $events-&gt;attach('ZfcUser\Form\RegisterFilter','init', function($e) {
              $filter = $e-&gt;getTarget();
  
              $filter-&gt;add(array(
                  'name'       =&gt; 'userlastname',
                  'required'   =&gt; true,
                  'filters'  =&gt; array(
                          array('name' =&gt; 'StripTags'),
                          array('name' =&gt; 'StringTrim'),
                  ),
                  'validators' =&gt; array(
                      array(
                          'name'    =&gt; 'StringLength',
                          'options' =&gt; array(
                              'min' =&gt; 3,
                              'max' =&gt; 255,
                          ),
                      ),
                  ),
             ));
          });
      }
  
      public function getConfig(){
          return array();
      }
  
      public function getAutoloaderConfig(){
          return array();
      }
  }
  </code></pre>
  
  <p>But after this I have got a bit lost on where/how to write the code to save the extra data that my new fields are gathering. </p>
  
  <ol>
  <li><p>Is this the event where I can fire off save routines for the additional fields <a href="https://github.com/ZF-Commons/ZfcUser/wiki/How-to-perform-a-custom-action-when-a-new-user-account-is-created">https://github.com/ZF-Commons/ZfcUser/wiki/How-to-perform-a-custom-action-when-a-new-user-account-is-created</a></p></li>
  <li><p>Should I be writing my own WbxUser model that extends ZfcUser\Entity\User.php to add my new fields</p></li>
  </ol>
  
  <p>I am a bit of a ZF and MVC noob so would be very great-full for a nudge in the write direction. </p>