I have a few checkboxes coming from nested model (:admin accepts_nested_attributes_for :account_setting). By default, the label for the checkbox is generated from the model’s attributes. But I want to use custom labels which I store in the locales folder as key value pairs.
This is the code,
= semantic_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :validate => true, :html => { :method => :put }) do |f|
= f.input :email
= f.inputs :receive_email_digest, :as =>:check_boxes, :for => :account_setting, :label => 'My custom label'
And it does not work. I tried :input_html, :member_label.
Does formtastic suppor this? Or do we have to hack it?
inputsis a fieldset. You’re telling formtastic to make a fieldset and ordered list with one list item and input,:receive_email_digest, which I presume is a boolean. The:ashere is not really having any effect, and:check_boxesis forhas_manyassociations.You want something like:
which will render two fieldsets each with a single input. Or perhaps even:
The semantic fields for here is merely a scope and shouldn’t output any markup.
I believe both of these will use
en.formtastic.labels.<resource_name>.account_setting.receive_email_digestfor the check box’s label, where resource name is whatever your resource’s underscored name is. Check out the formtastic source for how these keys are generated.