All of the above methods still leave you with form data nested inside the "user" or any other character that you pass as the first argument. This is annoying.
To mimic the style / benefits of simple_form, but remove the object / symbol dependency and nested data nesting, you can create a partial one.
Examples
HAML :
form view:
= form_tag("path/to/action", method: "POST") do = render "path/to/partial/field", type: "string", required: true, item: "first_name"
field partial:
- required_string = required ? "required" : "" %div{class: "input #{type} #{required_string} #{item}"} %label{class: "#{type} #{required_string}", for: "#{item}"} - if required %abbr{title: "required"} * = t("application.#{item}") %input{name: "#{item}", | placeholder: t("application.#{item}"), | type: "#{type}", | required: required, | "aria-required" => "#{required}" }
FreePender Nov 17 '14 at 17:44 2014-11-17 17:44
source share