title: OctoberCMS How To Create Custom User Registration Form With Fields From Plugin Extension
body: <p>I'm trying to learn OctoberCMS and I am confused about the complete process of extending plugins. I've extended the user plugin according to the screencast (<a href="https://vimeo.com/108040919">https://vimeo.com/108040919</a>). Ultimately, I'm looking to create a new field called "category" which wold store a users category. On a new page, I have the following form which I am trying to use to register a new user based solely on their e-mail address. The "category" is populated based on the page that they registered from and the password should be automatically generated so that the user will set it upon confirming their account from an e-mail activation link. My plugin is called "Profile".</p>
  
  <p>My plugin.php file looks like:</p>
  
  <pre><code>&lt;?php namespace Sser\Profile;
  
  use System\Classes\PluginBase;
  use RainLab\User\Models\User as UserModel;
  use RainLab\User\Controllers\Users as UsersController;
  use Sser\Profile\Models\Profile as ProfileModel;
  /**
   * Profile Plugin Information File
   */
  class Plugin extends PluginBase
  {
  
      /**
       * Returns information about this plugin.
       *
       * @return array
       */
      public function pluginDetails()
      {
          return [
              'name'        =&gt; 'Profile',
              'description' =&gt; 'Handles user demographic information',
              'author'      =&gt; '',
              'icon'        =&gt; 'icon-leaf'
          ];
      }
  
      public function boot()
      {
          UserModel::extend(function($model){
              $model-&gt;hasOne['profile'] = ['Sser\Profile\Models\Profile'];
          });
          // $user-&gt;profile-&gt;zip
  
          UserModel::deleting(function($user) {
              $user-&gt;profile-&gt;delete();
          });
  
          UsersController::extendFormFields(function($form,$model,$context){
              if(!$model instanceof UserModel)
              {
                  return;
              }
              if(!$model-&gt;exists)
              {
                  return;
              }
              //Ensures that a profile model always exists...
              ProfileModel::getFromUser($model);
  
              $form-&gt;addTabFields([
                  'profile[age]'=&gt;[
                      'label'=&gt;'Age',
                      'tab'=&gt;'Profile',
                      'type'=&gt;'number'
                  ],
                  'profile[gender]'=&gt;[
                      'label'=&gt;'Gender',
                      'tab'=&gt;'Profile',
                      'type'=&gt; 'dropdown',
                      'options'=&gt;array('male'=&gt;'Male',
                                       'female'=&gt;'Female')
  
                  ],
                  'profile[category]'=&gt;[
                      'label'=&gt;'Category',
                      'tab'=&gt;'Profile',
                      'type'=&gt; 'dropdown',
                      'options'=&gt;array('sink'=&gt;'SINK',
                                       'dink'=&gt;'DINK')
                  ],
                  'profile[vag]'=&gt;[
                      'label'=&gt;'VAG',
                      'tab'=&gt;'Profile',
                      'type'=&gt; 'dropdown',
                      'options'=&gt;array('v'=&gt;'V',
                                       'a'=&gt;'A',
                                       'g'=&gt;'G')
                  ]
              ]);
          });
      }
  
  }
  </code></pre>
  
  <p>My profile.php file looks like:</p>
  
  <pre><code>&lt;?php namespace Sser\Profile\Models;
  
  use Model;
  use \October\Rain\Database\Traits\Validation;
  
  /**
   * Profile Model
   */
  class Profile extends Model
  {
      public $rules = [
          'category' =&gt; ['required', 'min:0']
      ];
  
      /**
       * @var string The database table used by the model.
       */
      public $table = 'sser_profile_profiles';
  
      /**
       * @var array Guarded fields
       */
      protected $guarded = ['*'];
  
      /**
       * @var array Fillable fields
       */
      protected $fillable = [];
  
      /**
       * @var array Relations
       */
      public $hasOne = [];
      public $hasMany = [];
      public $belongsTo = [
          'user'=&gt; ['RainLab\User\Models\User']
      ];
      public $belongsToMany = [];
      public $morphTo = [];
      public $morphOne = [];
      public $morphMany = [];
      public $attachOne = [];
      public $attachMany = [];
  
      public static function getFromUser($user)
      {
          if($user-&gt;profile)
          {
              return $user-&gt;profile;
          }
  
          $profile = new static;
          $profile-&gt;user = $user;
          $profile-&gt;save();
  
          $user-&gt;profile = $profile;
  
          return $profile;
      }
  
  }
  </code></pre>
  
  <p>I am trying to create a user registration form that looks like the following:</p>
  
  <pre><code>&lt;form class="flexiContactForm col s12" role="form" data-request="{{ __SELF__ }}::onSignup" data-request-update="'{{ __SELF__ }}::confirm': '.confirm-container'"&gt;;
      &lt;button id="signup_button" class="waves-effect waves-light btn" style="float:right;" type="submit"&gt;Sign Up&lt;/button&gt;
      &lt;div style="overflow: hidden; padding-right:0em;"&gt;
      &lt;input id="signup_email" type="email" class="validate" name="email"&gt;            
      &lt;label id="signup_email_label" for="signup_email" data-error="" data-success=""&gt;Email Address&lt;/label&gt;
      &lt;input type="hidden" name="category" value="{{ data.category }}"/&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>What I am confused about is how to make an "onSignup" component that will basically extend the functionality of the user plugins "onRegister" component and then automatically generate a password and also save the "category" field. Can anyone provide an example or link to a page that shows an example of this? Thanks.</p>