Hobo Cookbook

View Source

Question: Question How do I add additional fields to the signup page?

Markdown Asks kevinpfromnm
I've got an extended model with fields for city, address, phone, fax
etc and yet they don't show up in my form signup. In my
application.dryml I've created:

<extend tag="signup-form" for="User">
<old-signup-form merge>
->>>
</old-signup-form >
</extend>

It is my understanding that this should give me the old form and
using

->>> <field-list: fields="city, province"/>

and the like where the arrow is should extend my form yet it gives me
a blank page and the form list overrides not appends the form. Also
when i try to override i often get

undefined method `confirm_password' for #<User:

and such. Depending on what the field name is. How and where do I fix
all that ?

Thanks in advance.

Discussion

  • when you change fields, it replaces the autoselected group so you need to include all the fields you want in the field-list. Since signup is controlled by a lifecycle, you need to add the parameters you want to the lifecycle signup transition declaration.

    app/models/user.rb lifecycle do

        state :active, :default => true
    
        create :signup, :available_to => "Guest",
               :params => [:name, :email_address, :password, :password_confirmation, :city, :province], # <-- added at end of params list
               :become => :active

    You shouldn’t need to override the form for the fields after adding those to the :params list as hobo will see that the two items should be passed as parameters and automatically add them to the form.