Development

#3489 (Form Helper ID Generation issues)

You must first sign up to be able to contribute.

Ticket #3489 (closed defect: wontfix)

Opened 7 months ago

Last modified 3 weeks ago

Form Helper ID Generation issues

Reported by: FabianLange Assigned to: fabien
Priority: major Milestone:
Component: helpers Version:
Keywords: id generation, form helper, radiobutton, radio Cc: Romain
Qualification: Design decision

Description (Last modified by FabianLange)

Normally I would not create such a collection ticket, but I try to sum all the related tickets and try to sum it up, so that this can be used as single point of contact. I also consider major as not enough for this issue. there are about a dozen tickets that describe this or a similar issue + multiple threads on the forum.

It all started with a fix of fabien in r6014 for #2327 The fix was applied to generate different IDs for radiobuttons. This was achieved by supplying a fake array name, which causes a helper method to make the id: name_value

#2833 mentions that the way value is used is incorrect as it can contain invalid characters. The ticket comments suggest even using a hash value rather then reencoding the value.

#3188 mentions that radiobuttons whose names are radio[] will also get the [] appended from r6014, which will result in the id being name_value_value

#2052, #1792 and #3009 say that actually the documentation is wrong because you should never make a radio named radio[], which actually would work, even though might not make obvious sense.

#2787 notes that the "magic" generation of IDs breaks for example label_for helper. The label_for helper is not aware that further magic is applied to generate an ID, but it would require exactly the same "magic" for all types of input fields. To solve #2787 it seems to be required that all input fields get their IDs generated in exactly the same way.

#2800 actually mentions that the hidden tag should generate the id same way as radiobutton tag

#1533 proposed a solution for the [][] replacement hacks, but doesn't seem sufficient for me.

#1761 asks for supporting '0' as value (!== null, not != null check), because otherwise value 0 will not get a id that follows the general name_value pattern.

In general it should be possible for the developer to "guess" what the ID will be. perhaps that ID should NOT depend on the value, as there might be unobstrusive JS that requires a known ID.

A note about BC: As it looks for me r6014 broke BC in sf 1.0.10 already, as the ID generation magic changed, and perhaps now is even more inconsistent. This looks like that it might be okay to implement a sound generation that might break (especially for radio button) BC, perhaps to actually restore BC

http://www.symfony-project.org/forum/index.php/t/10718/ http://www.symfony-project.com/forum/index.php?t=rview&th=6625

Change History

05/07/08 23:07:37 changed by FabianLange

  • description changed.

05/07/08 23:10:32 changed by FabianLange

  • description changed.

05/07/08 23:11:36 changed by FabianLange

Note: Tickets are marked as closed in the body of this ticket because I closed them being duplicates of this collection. The main issue of all those tickets is UNRESOLVED

05/07/08 23:23:49 changed by FabianLange

This needs to be fixed in sf 1.0 and sf 1.1. However the way of fixing it for both branches could be totally different. For sf 1.0 i see reverting r6014 and leaving the behavior as an option.

05/08/08 09:06:37 changed by FabianLange

one example I just used to show the issue:

Choose Pizza type:
<input type="radio" name="pizza[]" value="pan"/>
<input type="radio[]" name="pizza" value="oven"/>
Choose toppings:
<input type="checkbox" name="pizza[][]" value="salami"/>
<input type="checkbox" name="pizza[][]" value="tuna"/>
<input type="checkbox" name="pizza[][]" value="all available meat!"/>

lets say radio-ing a pan pizza with tuna and "all available meat!" will return a valid array

array: (0=>'pan',1=>array(0=>'tuna',1=>'all available meat!'))

05/08/08 10:47:09 changed by FabianLange

  • description changed.

06/29/08 22:41:23 changed by FabianLange

  • milestone changed from 1.1.0 to 1.1.1.

07/05/08 11:07:40 changed by Romain

  • cc set to Romain.

07/29/08 22:05:56 changed by nicolas

  • milestone changed from 1.1.1 to 1.1.2.

08/26/08 09:58:56 changed by nicolas

  • owner changed from fabien to FabianLange.

Fabian, what's the status of this ticket right now?

08/26/08 11:53:19 changed by FabianLange

  • version deleted.
  • milestone deleted.

i have no good idea. we could say: it cant be helped, but I dont think thats the way to go. But I also think this is something that is not targeted for a specific release. once we have a good idea ow to fix it, we should apply it to all maintained releases. Following tht proposal, I just unset the milestone and version field. ok?

11/09/08 17:42:28 changed by FabianLange

  • owner changed from FabianLange to fabien.

Fabien please briefly read this ticket, as we are advocating the use of the new form framework it does not seem to be a big issue anymore. Also the FormExtra? plugin brings Widgets that work much better now. I would propose closing this ticket, but I want to make sure you have solved most of these issues in the form framework. So please crosscheck and then close this ticket

11/09/08 18:42:17 changed by fabien

  • status changed from new to closed.
  • resolution set to wontfix.