mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
FIX: Replace ‘.’s with ‘_’s in HTML IDs
The functioning of dot-syntax in form fields mean that .s are more likely to appear in names. This breaks javascript behaviour in HTML IDs and I believe is an invalid character for them.
This commit is contained in:
parent
02fb7c3b17
commit
6ba7bf7b2f
@ -61,14 +61,17 @@ class FormTemplateHelper
|
||||
*/
|
||||
public function generateFieldID($field)
|
||||
{
|
||||
// Don't include '.'s in IDs, they confused JavaScript
|
||||
$name = str_replace('.', '_', $field->getName());
|
||||
|
||||
if ($form = $field->getForm()) {
|
||||
return sprintf(
|
||||
"%s_%s",
|
||||
$this->generateFormID($form),
|
||||
Convert::raw2htmlid($field->getName())
|
||||
Convert::raw2htmlid($name)
|
||||
);
|
||||
}
|
||||
|
||||
return Convert::raw2htmlid($field->getName());
|
||||
return Convert::raw2htmlid($name);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user