Open
Description
Feature
Within the action fields we can add required: true
but as required field option documentation points out, this is only cosmetic.
class Avo::Actions::FooBar < Avo::BaseAction
def fields
field :my_text, as: :text, required: true
end
This means anyone can submit the form while the browser could perfectly give some initial validation feedback.
Sidenote: this does not only apply to actions (also to the record edit forms), but is especially useful in actions as you don't have ActiveRecord validation that will automatically display upon submitting of the form -> meaning you need to add a lot more boilerplate in the handle
method
Current workarounds
part 1: proactive (not working yet)
Not working yet, but if we can extend html field option on top of style
, classes
, and data
to also allow for required?
field :my_text, as: :text, required: true,
html: {
edit: {
input: {
required: "true"
}
}
}
part 2: reactive (already working)
use keep_modal_open
def handle(fields:, **args)
if params[:my_text].blank
error "Something happened: #{error.message}"
keep_modal_open
return
end
# ...
end
Screenshots or screen recordings
Metadata
Metadata
Assignees
Type
Projects
Status
Backlog