Note that there are some explanatory texts on larger screens.

plurals
  1. POZfcUser - How can I modify user object
    text
    copied!<p>I have modified ZfcUser register form in my module (Module.php) with two new fields "firstname" and "lastname" like this:</p> <pre><code>public function onBootstrap($e) { $events = $e-&gt;getApplication()-&gt;getEventManager()-&gt;getSharedManager(); $zfcServiceEvents = $e-&gt;getApplication()-&gt;getServiceManager()-&gt;get('zfcuser_user_service')-&gt;getEventManager(); $events-&gt;attach('ZfcUser\Form\Register', 'init', function($e) { $form = $e-&gt;getTarget(); $form-&gt;add(array( 'name' =&gt; 'firstname', 'type' =&gt; 'Text', 'options' =&gt; array( 'label' =&gt; 'First name: ', ), )); $form-&gt;add(array( 'name' =&gt; 'lastname', 'type' =&gt; 'Text', 'options' =&gt; array( 'label' =&gt; 'Last name: ', ), )); }); $events-&gt;attach('ZfcUser\Form\RegisterFilter', 'init', function($e) { $filter = $e-&gt;getTarget(); $filter-&gt;add(array( 'name' =&gt; 'firstname', 'required' =&gt; true, 'validators' =&gt; array( array( 'name' =&gt; 'StringLength', 'options' =&gt; array( 'min' =&gt; 3, 'max' =&gt; 255, ), ), ), )); $filter-&gt;add(array( 'name' =&gt; 'lastname', 'required' =&gt; true, 'validators' =&gt; array( array( 'name' =&gt; 'StringLength', 'options' =&gt; array( 'min' =&gt; 3, 'max' =&gt; 255, ), ), ), )); }); $zfcServiceEvents-&gt;attach('register', function($e) { $user = $e-&gt;getParam('user'); // User account object $form = $e-&gt;getParam('form'); // Form object //var_dump($form-&gt;get('firstname')-&gt;getValue()); die; //var_dump($user); die; }); $zfcServiceEvents-&gt;attach('register.post', function($e) { $user = $e-&gt;getParam('user'); }); } </code></pre> <p>Registration form looks ok. I can see to additional fields and validation is working fine. Problem is that I can't set this two new fields in user object:</p> <pre><code>$user-&gt;setFirstname($form-&gt;get('firstname')-&gt;getValue()); </code></pre> <p>It is saying that this property doesn't exists. Can you explain what I'm doing wrong please?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload