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

New feature: field hints for forms inputs #2405

Merged
merged 1 commit into from
Dec 12, 2023
Merged

New feature: field hints for forms inputs #2405

merged 1 commit into from
Dec 12, 2023

Conversation

blocknotes
Copy link
Contributor

@blocknotes blocknotes commented Jul 29, 2023

Hey!
Thank you for the nice gem! 😄
I use it from quite some time and now I'm here to propose a small feature: adding optional hints (as small text lines) below form input fields.
I'm opening the PR in draft as proof of concept, if you like the idea I could complete it (with tests / anything needed).

I'm using this feature in a couple of projects, I think it can help offering context information to the users.

The changes should be minimal, I just added a div below div.field-unit__field and set basic styles for the new element.
I also had to add flex-wrap: wrap; to .field-unit in order to place the new div on a new line.
In another version I was passing the hint via field options but now I prefer the translations way because in any case the string would be stored there for my projects.

Sample locale:

en:
  administrate:
    field_hints:
      book:
        content: Brief summary of the book

The effect is like the following:

image

Please let me know your opinion 🙏

@pablobm
Copy link
Collaborator

pablobm commented Aug 11, 2023

Nice! I like the idea and I think using i18n is the way to go 👍

As well as a test, would you be able to put together a bit of documentation? Perhaps under https://github.com/thoughtbot/administrate/blob/main/docs/customizing_dashboards.md

Thank you @blocknotes!

@blocknotes blocknotes closed this Aug 21, 2023
@blocknotes blocknotes reopened this Aug 21, 2023
@blocknotes blocknotes changed the title proposal: add field hints to the forms? New feature: field hints for forms inputs Aug 22, 2023
@blocknotes blocknotes marked this pull request as ready for review August 22, 2023 21:27
@blocknotes
Copy link
Contributor Author

Hey @pablobm,
I should have set up the required changes; I put the PR in Ready for review.
Please let me know if you spot something.

This allows us to show a hint, based on a translation, underneath a form
field to provide further context on the field.

For example:

    en:
      administrate:
        field_hints:
          book:
            content: Brief summary of the book

"Brief summary of the book" will then be shown under the Content field
of a dashboard including a Book.
@nickcharlton
Copy link
Member

Thanks! This is a nice little feature I've wanted in the past, but never got around to do anything about it!

I just rebased it, and I'll merge it shortly.

@nickcharlton nickcharlton merged commit 8e7bb22 into thoughtbot:main Dec 12, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants