Skip to content
Looking for every option?See the full API reference →

Radio ​

The Radio field renders a group of choices where only one value can be selected. Use it for a short list of choices that should all be visible on the form.

ruby
# app/avo/resources/user.rb
field :role,
  as: :radio,
  name: "User role",
  options: {
    admin: "Administrator",
    manager: "Manager",
    writer: "Writer"
  }

Without configuration, the field has no choices. Configured choices render as standard radio buttons, and the index and show views display the label matching the stored value.

Choose the available values ​

Set options to a hash whose keys are the values submitted by the form and whose values are the visible labels, as in the example above.

If choices depend on the current record, use a block returning the same hash shape. The block has access to Avo::ExecutionContext, including record, resource, view, and field.

ruby
# app/avo/resources/user.rb
field :role_id, as: :radio, options: -> do
  record.roles.each_with_object({}) do |role, choices|
    choices[role.id] = role.name.humanize
  end
end

Show choices as tabs ​

Set display_as to :tabs for a tab-style switcher instead of standard radio buttons. Both styles submit the selected option's key.

ruby
# app/avo/resources/user.rb
field :role, as: :radio, display_as: :tabs, options: { admin: "Administrator", writer: "Writer" }

Display stored values instead of labels ​

If you want the index and show views to display the stored value rather than its label, enable display_value. This does not change the form labels.

ruby
# app/avo/resources/user.rb
field :role, as: :radio, display_value: true, options: { admin: "Administrator", writer: "Writer" }

When no label matches, these views fall back to the stored value. A nil value displays a dash.

Options reference ​

See the Radio API for all field-specific options, defaults, and choice-matching behavior.

For shared settings such as visibility, defaults, and help text, see Common field options.