Skip to content

Commit

Permalink
Merge branch 'main' of github.com:avo-hq/avodocs
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianthedev committed Apr 12, 2024
2 parents deb0f2e + 6a84f99 commit 020ce32
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions docs/3.0/fields/boolean_group.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,26 @@ field :roles, as: :boolean_group, name: 'User roles', options: { admin: 'Adminis
warning: :warning
}
```

#### Computed options

You may want to compute the values on the fly for your `BooleanGroup` field. You can use a lambda for that where you have access to the `record`, `resource`, `view`, and `field` properties where you can pull data off.

```ruby{5-7}
# app/avo/resources/project.rb
class Avo::Resources::Project < Avo::BaseResource
field :features,
as: :boolean_group,
options: -> do
record.features.each_with_object({}) do |feature, hash|
hash[feature.id] = feature.name.humanize
end
end
end
```

The output value must be a hash as described above.

:::

## Example DB payload
Expand Down

0 comments on commit 020ce32

Please sign in to comment.