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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

balvig
Copy link

@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 and others added 3 commits September 30, 2024 11:25
Co-authored-by: Nick Charlton <[email protected]>
```
NoMethodError:
undefined method `render' for #<RSpec::ExampleGroups::FieldsTextForm "doesn't require input options" (./spec/administrate/views/fields/text/_form_spec.rb:18)>
```

https://github.com/thoughtbot/administrate/actions/runs/11098287221/job/30909674170?pr=2665
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