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

Allow configuring text field input options #2665

Merged
merged 1 commit into from
Oct 15, 2024

Conversation

balvig
Copy link
Contributor

@balvig balvig commented Sep 27, 2024

What

Allows configuring the rendered <textarea> for Field::Text fields, e.g.:

ATTRIBUTE_TYPES = {
  body: Field::Text.with_options(input_options: { rows: 20 }),
}.freeze

Result in:

<textarea rows="20" name="post[body]" id="post_body">...</textarea>

Why

The main use case for this was being able to scale up text areas when needed, f.ex:

Before After
Edit CoachingContent #3 - Moment Web2024-09-27 at 11 53 31@2x Edit CoachingContent #3 - Moment Web2024-09-27 at 11 53 12@2x

How

This provides a generic input_options to access all the options provided by text_area, but if that feels like overkill, it could also be hardcoded to only support rows?

@balvig balvig marked this pull request as ready for review September 27, 2024 03:05
Copy link
Member

@nickcharlton nickcharlton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a lovely improvement, thanks!

I just triggered the CI run, too.

spec/administrate/views/fields/text/_form_spec.rb Outdated Show resolved Hide resolved
@balvig balvig requested a review from nickcharlton October 3, 2024 04:48
This allows configuring the rendered `<textarea>` for `Field::Text`
fields, e.g.:

    ATTRIBUTE_TYPES = {
      body: Field::Text.with_options(input_options: { rows: 20 }),
    }.freeze

Will render:

    <textarea rows="20" name="post[body]" id="post_body">...</textarea>
@nickcharlton nickcharlton force-pushed the jb/textarea-input-options branch from 9916ec6 to fb8e4af Compare October 15, 2024 12:25
Copy link
Member

@nickcharlton nickcharlton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this! And finding out that we do need type: view, too!

@nickcharlton nickcharlton merged commit 3cd1315 into thoughtbot:main Oct 15, 2024
10 checks passed
@balvig balvig deleted the jb/textarea-input-options branch October 16, 2024 00:48
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.

2 participants