1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
- form_for :user, :url => users_path do |f| %ul.register %li %label{:for => 'user_login'} %strong 1. Login %span.req * %div = f.text_field :login, :size => '0', :class => 'full text' %label.desc What you login with %li %label{:for => 'user_email'} %strong 2. Email %span.req * %div = f.text_field :email, :size => '0', :class => 'full text' %label.desc We will never sell or disclose your email to any third parties %li.clear .left %label{:for => 'user_password'} %strong 3. Password %span.req * = f.password_field :password, :size => '0', :class => 'full text' %label.desc At least 6 characters long .right %label{:for => 'user_password_confirmation'} %strong 4. Confirm Password %span.req * = f.password_field :password_confirmation, :size => '0', :class => 'full password text' %li = f.check_box :receive_updates %label.choice{:for => 'user_receive_updates'} Keep me updated on WB = f.check_box :terms_of_service %label.choice{:for => 'user_terms_of_service'} I agree to WB's <a href="#">Terms of Service</a> %li.buttons <button type="submit" class="button positive"> <img src="stylesheets/blueprint/plugins/buttons/icons/tick.png" alt=""/> Register! </button> = link_to(image_tag('/stylesheets/blueprint/plugins/buttons/icons/cross.png') + "Cancel", home_url, :class => 'button negative')
Refactorings
No refactoring yet !
Ben Burkert
December 11, 2007, December 11, 2007 04:56, permalink
Are you asking how to build a form with haml? Or do you want to refactor the haml into erb?
Daniel Fischer
December 11, 2007, December 11, 2007 07:40, permalink
How would I build it with haml? Sorry for the confusion.
Ben Burkert
December 11, 2007, December 11, 2007 23:04, permalink
Haml is a templating engine that can be used instead of erb. take a look:
http://haml.hamptoncatlin.com/
Daniel Fischer
December 12, 2007, December 12, 2007 01:54, permalink
I know what HAML is, I wrote all my code in HAML as you can see.
What I want to do is reduce duplication of all my forms. So how would I refactor my above haml code into a form helper that outputs the text_field with labels like in my example?
Dean
December 18, 2007, December 18, 2007 11:31, permalink
1 2 3
script/plugin install svn://rubyforge.org/var/svn/cssformbuilder/trunk ;)
I have no idea how to create custom form builders, if anyone could look at the following view code and refactor it into a method that builds out forms / fields with the appropriate divs that would be amazing. Thanks!