Skip to content
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

An user submitting a form should be able to see what fields are required. #1489

Closed
ACPK opened this issue Dec 12, 2019 · 3 comments
Closed
Labels
feature new functionality that’s not yet implemented views-and-styles how administrate looks and is interacted with

Comments

@ACPK
Copy link

ACPK commented Dec 12, 2019

When rendering a field, a user should be able to see what fields are required. Has anyone else implemented this as I'd be happy to do a PR?

@ACPK ACPK added the feature new functionality that’s not yet implemented label Dec 12, 2019
@pablobm
Copy link
Collaborator

pablobm commented Dec 28, 2019

Hello @ACPK. I'm not aware of any work on this. I'd be happy to see a PR.

What do you have in mind? Happy to discuss before providing code too.

@nickcharlton nickcharlton added the views-and-styles how administrate looks and is interacted with label Jan 2, 2020
@davi-tapajos-codeminer42
Copy link
Contributor

Hey!
What you guys think about it?

Captura de Tela 2020-01-09 às 17 20 38

<% page.attributes.each do |attribute| -%>
  <div class="field-unit field-unit--<%= attribute.html_class %> <%= required_field?(attribute) %>">
    <%= render_field attribute, f: f %>
  </div>
<% end -%>
def required_field?(field)
  'required' if field.resource.class.validators_on(field.attribute).map(&:class).include?(ActiveRecord::Validations::PresenceValidator)
end

pablobm pushed a commit that referenced this issue Jan 25, 2020
Displays an asterisk beside label on form when field is required

Issue: #1489

![Captura de Tela 2020-01-09 às 17 20 38](https://user-images.githubusercontent.com/54637230/72172195-55363580-33b3-11ea-8475-edb4520b276d.png)
@pablobm
Copy link
Collaborator

pablobm commented Jan 25, 2020

Fixed at #1521

@pablobm pablobm closed this as completed Jan 25, 2020
KingTiger001 added a commit to KingTiger001/admin-Rails-project that referenced this issue Jan 15, 2023
Displays an asterisk beside label on form when field is required

Issue: thoughtbot/administrate#1489

![Captura de Tela 2020-01-09 às 17 20 38](https://user-images.githubusercontent.com/54637230/72172195-55363580-33b3-11ea-8475-edb4520b276d.png)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature new functionality that’s not yet implemented views-and-styles how administrate looks and is interacted with
Projects
None yet
Development

No branches or pull requests

4 participants