mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
FIX: Generate Form::FormName() through
This commit is contained in:
parent
5acf2aab94
commit
c7468caeb6
@ -928,11 +928,7 @@ class Form extends RequestHandler {
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function FormName() {
|
public function FormName() {
|
||||||
if($this->htmlID) {
|
return $this->getTemplateHelper()->generateFormID($this);
|
||||||
return $this->htmlID;
|
|
||||||
} else {
|
|
||||||
return $this->class . '_' . str_replace(array('.', '/'), '', $this->name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -41,7 +41,9 @@ class FormTemplateHelper {
|
|||||||
return Convert::raw2htmlid($id);
|
return Convert::raw2htmlid($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Convert::raw2htmlid($form->FormName());
|
return Convert::raw2htmlid(
|
||||||
|
get_class($form) . '_' . str_replace(array('.', '/'), '', $form->getName())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -63,7 +65,7 @@ class FormTemplateHelper {
|
|||||||
public function generateFieldID($field) {
|
public function generateFieldID($field) {
|
||||||
if($form = $field->getForm()) {
|
if($form = $field->getForm()) {
|
||||||
return sprintf("%s_%s",
|
return sprintf("%s_%s",
|
||||||
$form->getHTMLID(),
|
$this->generateFormID($form),
|
||||||
Convert::raw2htmlid($field->getName())
|
Convert::raw2htmlid($field->getName())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -93,7 +95,10 @@ class FormTemplateHelper_Pre32 extends FormTemplateHelper {
|
|||||||
return $id;
|
return $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $form->class . '_' . str_replace(array('.', '/'), '', $form->getName());
|
return sprintf("%s_%s",
|
||||||
|
$form->class,
|
||||||
|
str_replace(array('.', '/'), '', $form->getName())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -111,10 +116,18 @@ class FormTemplateHelper_Pre32 extends FormTemplateHelper {
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function generateFieldID($field) {
|
public function generateFieldID($field) {
|
||||||
$name = preg_replace('/(^-)|(-$)/', '', preg_replace('/[^A-Za-z0-9_-]+/', '-', $field->getName()));
|
$name = preg_replace(
|
||||||
|
'/(^-)|(-$)/', '',
|
||||||
|
preg_replace('/[^A-Za-z0-9_-]+/', '-', $field->getName())
|
||||||
|
);
|
||||||
|
|
||||||
if($form = $field->getForm()) {
|
if($form = $field->getForm()) {
|
||||||
return $form->FormName() . '_' . $name;
|
$form = sprintf("%s_%s",
|
||||||
|
get_class($form),
|
||||||
|
str_replace(array('.', '/'), '', $form->getName())
|
||||||
|
);
|
||||||
|
|
||||||
|
return $form . '_' . $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $name;
|
return $name;
|
||||||
|
Loading…
Reference in New Issue
Block a user