-
Notifications
You must be signed in to change notification settings - Fork 1
COR-622: Error Message Cue #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -2,6 +2,10 @@ module Plugins | |||
module Core | |||
class Cell < FieldCell | |||
view_paths << "#{Cortex::Plugins::Core::Engine.root}/app/cells" | |||
|
|||
def required? | |||
field_item.field.validations["presence"] == true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know we've used "presence" for a while but why name the validation "presence" and not "required"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because presence is what Rails / ActiveModel use to reference required validations - basically it's just to keep it consistent with how Rails does things and not change too many keywords
@@ -2,6 +2,10 @@ module Plugins | |||
module Core | |||
class Cell < FieldCell | |||
view_paths << "#{Cortex::Plugins::Core::Engine.root}/app/cells" | |||
|
|||
def required? | |||
field_item.field.validations["presence"] == true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can just return field_item.field.validations["presence"]
and nothing else and achieve the same effect - no need for a comparison
@@ -14,7 +14,7 @@ def value | |||
end | |||
|
|||
def render_select | |||
@options[:form].select 'data[user_id]', user_data_for_select, {selected: value} | |||
@options[:form].select 'data[user_id]', user_data_for_select, {selected: value}, required: required? | |||
end | |||
|
|||
def user_data_for_select |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume adding required
to fields like file
didn't do anything? Just checking - we said we'd try (and drop it quickly), so just making sure that was looked into
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only applied it to fields that would trigger the HTML5 validation, which means that only DateTime (text input), Float / Integer (Number Field), Tag (Text Input), Text (Text Input), and User (Dropdown Select) have the ability to have on form HTML5 required validations
Uses the globally accessible
#required?
method to check and apply HTML5 presence validations based on the associated validation data we pull from the givenfield_item