Sha256: 6eb1cfb1ebe6f1bcf1d559fb73f2bc2e6e2900ea5e45f44cac5868b3d36d91cf

Contents?: true

Size: 1.23 KB

Versions: 89

Compression:

Stored size: 1.23 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:

```
<%= 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:

```
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:

```
<%= 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:

```
<%= render 'shared/fields/buttons', form: form, method: :category_ids,
  options: Category.all.map { |category| [category.id, category.label_string] }, multiple: true %>
```

Version data entries

89 entries across 89 versions & 1 rubygems

Version Path
bullet_train-1.2.27 docs/field-partials/buttons.md
bullet_train-1.2.26 docs/field-partials/buttons.md
bullet_train-1.2.25 docs/field-partials/buttons.md
bullet_train-1.2.24 docs/field-partials/buttons.md
bullet_train-1.2.23 docs/field-partials/buttons.md
bullet_train-1.2.22 docs/field-partials/buttons.md
bullet_train-1.2.21 docs/field-partials/buttons.md
bullet_train-1.2.20 docs/field-partials/buttons.md
bullet_train-1.2.19 docs/field-partials/buttons.md
bullet_train-1.2.18 docs/field-partials/buttons.md
bullet_train-1.2.17 docs/field-partials/buttons.md
bullet_train-1.2.16 docs/field-partials/buttons.md
bullet_train-1.2.15 docs/field-partials/buttons.md
bullet_train-1.2.14 docs/field-partials/buttons.md
bullet_train-1.2.13 docs/field-partials/buttons.md
bullet_train-1.2.12 docs/field-partials/buttons.md
bullet_train-1.2.11 docs/field-partials/buttons.md
bullet_train-1.2.10 docs/field-partials/buttons.md
bullet_train-1.2.9 docs/field-partials/buttons.md
bullet_train-1.2.8 docs/field-partials/buttons.md