This project is archived and is in readonly mode.
FormHelper's auto_index should create more "friendly" ids or revert back to id_before_type_cast
-
Brian Johnson
This ticket is a perfect example of why to_param seems like the wrong thing to do. Imagine an id that is ticket_2840-formhelpers-auto_index-should-create-more-friendly-ids-or-revert-back-to-id_before_type_cast_comment
Doesn't that seem a little ridiculous? -
Yehuda Katz (wycats)
- State changed from new to wontfix
It seems like changing this at this point would potentially break people's JavaScript code that rely on the existing behavior for marginal benefit. Can you clarify a bit more what the significant improvement would be that justifies the breakage? Can you provide some examples?
I'm marking this as wontfix but would be open to revisiting this with some more compelling examples.
-
Brian Johnson
what about at least removing . and : from the allowed characters? Technically they're legal, but they do cause issues. I started this ticket because I had a to_param method with a . in it that broke my javascript code and css selectors in Firefox and then I thought it would be better to just use the ID. If your to_param method has a dot in it, css would interpret that as a class selector.
-
Brian Johnson
another option would be an option :index => :id_before_type_cast where the symbol would be any method you want to run as the index parameter
-
Brian Johnson
if you think that would work, I can come up with a patch, but I don't want to spend time on something that isn't going to be used.
-
Yehuda Katz (wycats)
- Assigned user set to Yehuda Katz (wycats)
@brian hmmm... I just wanted to point out that at least the jQuery selector engine supports escaping, so you could do $("#myid\.id") or $("#myid\:id") just fine. I'll give this a bit more thought after lunch.
-
Brian Johnson
What about this?
@@@html
#test.dot {color: red;}
test
-
Brian Johnson
I'll try that again
<html> <style> #test.dot { color: red; } </style> <body> <div id="test.dot">test</div> </body> </html> -
Brian Johnson
forget it, you can escape there too with .
-
Brian Johnson
so I guess maybe there is no real issue with . or : in general, but it doesn't change the fact that it would be nice to have the option to use the id instead. I think the :index => :method_name is a good way to go.
-
Yehuda Katz (wycats)
- State changed from wontfix to hold
@brian If you can make a patch that only adds a net line or two, I'm game!
-
Yehuda Katz (wycats)
- State changed from hold to incomplete
-
Brian Johnson
ok, I needed two lines to cover nested forms. I used method(method_name).call instead of send because the test was failing on the Structs in the tests, not sure if there is a better way to deal with that.
-
Rohit Arondekar
- State changed from incomplete to stale
- Importance changed from to
Marking ticket as stale. If this is still an issue please leave a comment with suggested changes, creating a patch with tests, rebasing an existing patch or just confirming the issue on a latest release or master/branches.
