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:
Sam Minnee 2019-08-24 17:12:26 +12:00 committed by Ingo Schommer
parent 02fb7c3b17
commit 6ba7bf7b2f

View File

@ -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);
}
}