Sha256: d03ceabe466000173d59d8ea4a7e4bf47c795b56fb678f892c5e797b33b150de
Contents?: true
Size: 1.24 KB
Versions: 40
Compression:
Stored size: 1.24 KB
Contents
# Examples for the `buttons` Field Partial ## Define Available Buttons via Localization Yaml If you invoke the field partial in `app/views/account/some_class_name/_form.html.erb` like so: ```erb <%= render 'shared/fields/buttons', form: form, method: :enabled %> ``` You can define the available buttons in `config/locales/en/some_class_name.en.yml` like so: ```yaml en: some_class_name: fields: enabled: name: &enabled Enabled label: Should this item be enabled? heading: Enabled? options: yes: "Yes, this item should be enabled." no: "No, this item should be disabled." ``` ## Generate Buttons Programmatically You can generate the available buttons using a collection of database objects by passing the `options` option like so: ```erb <%= render 'shared/fields/buttons', form: form, method: :category_id, options: Category.all.map { |category| [category.id, category.label_string] } %> ``` ## Allow Multiple Button Selections You can allow multiple buttons to be selected using the `multiple` option, like so: ```erb <%= render 'shared/fields/buttons', form: form, method: :category_ids, options: Category.all.map { |category| [category.id, category.label_string] }, multiple: true %> ```
Version data entries
40 entries across 40 versions & 1 rubygems