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

Label form helper errors when provided a symbol #1422

Closed
dcr8898 opened this issue Jun 15, 2024 · 0 comments · Fixed by #1423
Closed

Label form helper errors when provided a symbol #1422

dcr8898 opened this issue Jun 15, 2024 · 0 comments · Fixed by #1423

Comments

@dcr8898
Copy link
Contributor

dcr8898 commented Jun 15, 2024

Summary

When provided a symbol argument, the label form helper produces an error.

Expected behavior

I'm not sure what the correct actual behavior is, so this may not be an issue at all. In all of the examples in the API docs, and in the unpublished guide, for form_for and its related helpers, all of the name/content method arguments are shown as strings. However, I noticed that some of the tests (notably the fields_for_collection tests) use symbol arguments.

If symbols are acceptable arguments, then label does not currently parse them correctly.

When the following erb template is used:

<%= form_for("/books") do |f| %>
  <%= f.label :free_shipping %>
<% end %>

It should produce:

<label for="free-shipping">Free shipping</label>

Actual behavior

Instead, an error is produced:

undefined method `split' for :free_shipping:Symbol

Discussion

If symbols should be accepted as the content argument to the label form helper, the accompanying pull request includes a fix.

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 a pull request may close this issue.

1 participant