Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # from tagged_builder.rb, included as a FormBuilder helper
- def self.create_tagged_field(method_name)
- define_method(method_name) do |label, *args|
- @template.content_tag("p",
- @template.content_tag("label" ,
- label.to_s.humanize.capitalize,
- :for => "#{@object_name}_#{label}")
- +
- super)
- end
- end
- <p><label>Name
- <span class="small">Add your name</span>
- </label>
- <input type="text" name="textfield" id="textfield" />
- <p><label for="object_name">Name</label></p>
- def self.create_tagged_field(method_name)
- define_method(method_name) do |label, warning, *args|
- @template.content_tag("p",
- @template.content_tag("label" ,
- label.to_s.humanize.capitalize+
- content_tag("span", warning),
- :for => "#{@object_name}_#{label}")
- +
- super)
- end
- end
- def self.create_tagged_field(method_name)
- define_method(method_name) do |label, *args|
- # accepts the warning hash from text_field helper
- if (args.first.instance_of? Hash) && (args.first.keys.include? :warning)
- warning = args.first[:warning]
- end
- @template.content_tag("label" , label.to_s.humanize+(@template.content_tag("span", warning, :class =>'small')),
- :for => "#{@object_name}_#{label}") +
- super
- end
- end
- def self.create_tagged_field(method_name)
- define_method(method_name) do |label, *args|
- @template.content_tag("p",
- @template.content_tag("label" , labels.to_s.humanize+(@template.content_tag("span", args[:warning]) unless !args[:warning]), :for => "#{@object_name}_#{label}") +
- super)
- end
- end
- <%= form.text_field :name, :warning => "dont do that"] %>
- Symbol as array index
Add Comment
Please, Sign In to add comment