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

text_area method is not providing either id or name attributes #32

Closed
josemotanet opened this issue Aug 21, 2015 · 8 comments
Closed

text_area method is not providing either id or name attributes #32

josemotanet opened this issue Aug 21, 2015 · 8 comments
Labels
Milestone

Comments

@josemotanet
Copy link
Contributor

The title is self-explanatory but here's my own example:

Code

form_for :event, "/events", class: "row" do
  text_area :notes, placeholder: "Some text here.", class: "form-control", rows: 6
end

Output

<form action="/events" method="post" class="row" id="event-form">
  <textarea rows="6" class="form-control" placeholder="Some text here"></textarea>
</form>

It is expected that the textarea has:

  • A name attribute with the value of event[notes];
  • An id attribute with the value of event-note.

EDIT: The root cause of the bug is the inability to store both name and id when no content is passed in. Check the discourse

@runlevel5 runlevel5 added the bug label Aug 22, 2015
@runlevel5 runlevel5 added this to the v0.2.1 milestone Aug 22, 2015
@runlevel5
Copy link
Member

Good find, would you be able to submit a PR? TIA

@pascalbetz
Copy link

Without looking into the code: shouldn't it be:

form_for :event, "/events", class: "row" do |f|
  f.text_area :notes, placeholder: "Some text here.", class: "form-control", rows: 6
end

(Form builder passed as a block argument).

@runlevel5
Copy link
Member

@pascalbetz nope

eg:

form_for :book, routes.books_path do
    text_field :title

    submit 'Create'
  end

@josemotanet
Copy link
Contributor Author

@joneslee85 yes, absolutely. You'll need to give me some time, though. My wife is in the hospital, it seems that my baby wants to be born any hour now. :) I'll be in touch.

@AlfonsoUceda
Copy link
Contributor

@josemota you are right, it should be like the example https://github.com/lotus/helpers#view-usage

congrants for the baby!

@pascalbetz
Copy link

@joneslee85 i was referring to the first example at http://lotusrb.org/guides/helpers/forms/ but without checking the text below. Argh.

@josemota : all the best!

@josemotanet
Copy link
Contributor Author

@joneslee85 @pascalbetz My baby's been born! She's growing steadily now in the incubator for some time. Until then, I'll be on the lookout but I'll try and squeeze in some time to work something out.

Please bear with me :)

@josemotanet
Copy link
Contributor Author

I've found the cause of this bug. It seems that not passing any content while still passing other HTML options to the method will simply not register either name or id.

text_area :notes, "forced content", rows: 1 # expected behavior is met
text_area :notes, rows: 1 # expected behavior is NOT met

I recall there's a place in the code where both of these are handled so I'll dig deeper. I'll edit the initial message with this mention for better contextualization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants