Closed (outdated)
Project:
Drupal core
Version:
6.19
Component:
forms system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
19 Apr 2010 at 13:55 UTC
Updated:
2 Mar 2016 at 22:18 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
thekevinday commentedOops, I prematurely hit Save.
The end result CSS ID would be:
Heres-is-a-valid-radio-button-item;-however,-the-CSS-ID-tag-will-put-a-semicolon-and-command-in-the-idThis is invalid as far as I can tell and cannot be properly modified via CSS.
I also discovered that other symbols such as the period
., parenthesis(), and so on.. will also end up in the ID tag when it should not.Comment #2
thekevinday commentedAfter doing some searching around in the code, I could not find a place in CCK where this is being set.
Instead, I looked into Drupal core and found the function form_id_clean: http://api.drupal.org/api/function/form_clean_id/6
The relevant line is:
That is far too few cases.
Instead, something like the following could be used:
But the next problem here is different languages.
So, I decided that a regular expression would work better as this allows for more language independent symbol replacements:
I left the existing str_replace for two reasons:
1) the underscore symbol '_' is considered a Word character and will not get replaced by the given preg_replace function
2) I don't know what is going on with the '][' case.
I have a patch for review that fixes this case.
Comment #4
sreynen commentedThis patch simply backports the cleaning code from D7's drupal_clean_css_identifier.
Comment #6
thekevinday commentedUnfortunately the patch you provided breaks things like views module's Live preview.
My patch works without any problems that I have noticed.
As far as your patch, I did a diff between a working views view and your backport shows that:
Before your patch the relevant view html looks like:
edit-live-previewAfter your patch the relevant view html looks like:
edit-live_previewComment #7
sreynen commented@thekevinday, I was thinking the work in D7 happened after your patch and likely received more attention so that was the best place to pick this up again. I think I put the new line in the wrong place on the last patch.
Comment #8
sreynen commentedComment #10
thekevinday commentedThis latest one is working so far.
Comment #11
gábor hojtsyHm, looking at http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_cl... it seems to have other differences as well. Like [ converted to - but ] removed (which is not the same as converting ][ to -). Also, it has / converted to -. Finally, it has some valuable docs, that is really lacking here. Let's not introduce a list of cryptic looking regex items without explaining them.