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

Version Path
bullet_train-1.5.1 docs/field-partials/buttons.md
bullet_train-1.5.0 docs/field-partials/buttons.md
bullet_train-1.4.11 docs/field-partials/buttons.md
bullet_train-1.4.10 docs/field-partials/buttons.md
bullet_train-1.4.9 docs/field-partials/buttons.md
bullet_train-1.4.8 docs/field-partials/buttons.md
bullet_train-1.4.7 docs/field-partials/buttons.md
bullet_train-1.4.6 docs/field-partials/buttons.md
bullet_train-1.4.5 docs/field-partials/buttons.md
bullet_train-1.4.4 docs/field-partials/buttons.md
bullet_train-1.4.3 docs/field-partials/buttons.md
bullet_train-1.4.2 docs/field-partials/buttons.md
bullet_train-1.4.1 docs/field-partials/buttons.md
bullet_train-1.4.0 docs/field-partials/buttons.md
bullet_train-1.3.25 docs/field-partials/buttons.md
bullet_train-1.3.24 docs/field-partials/buttons.md
bullet_train-1.3.23 docs/field-partials/buttons.md
bullet_train-1.3.22 docs/field-partials/buttons.md
bullet_train-1.3.21 docs/field-partials/buttons.md
bullet_train-1.3.20 docs/field-partials/buttons.md