mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX #5833 Duplicate IDs when two similar date formats in Member_DatetimeOptionsetField containing different delimiters (e.g / and .) replaced to an empty string (from r108001)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112703 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
0e3693f99e
commit
7254c00aef
@ -1844,7 +1844,8 @@ class Member_DatetimeOptionsetField extends OptionsetField {
|
|||||||
$source = $this->getSource();
|
$source = $this->getSource();
|
||||||
|
|
||||||
foreach($source as $key => $value) {
|
foreach($source as $key => $value) {
|
||||||
$itemID = $this->id() . "_" . ereg_replace('[^a-zA-Z0-9]+', '', $key);
|
// convert the ID to an HTML safe value (colons are not replaced, as they are valid in an ID attribute)
|
||||||
|
$itemID = $this->id() . '_' . preg_replace('/[^\.a-zA-Z0-9\-\_]/', '_', $key);
|
||||||
if($key == $this->value) {
|
if($key == $this->value) {
|
||||||
$useValue = false;
|
$useValue = false;
|
||||||
$checked = " checked=\"checked\"";
|
$checked = " checked=\"checked\"";
|
||||||
@ -1856,8 +1857,9 @@ class Member_DatetimeOptionsetField extends OptionsetField {
|
|||||||
$extraClass = $odd ? "odd" : "even";
|
$extraClass = $odd ? "odd" : "even";
|
||||||
$extraClass .= " val" . preg_replace('/[^a-zA-Z0-9\-\_]/', '_', $key);
|
$extraClass .= " val" . preg_replace('/[^a-zA-Z0-9\-\_]/', '_', $key);
|
||||||
$disabled = ($this->disabled || in_array($key, $this->disabledItems)) ? "disabled=\"disabled\"" : "";
|
$disabled = ($this->disabled || in_array($key, $this->disabledItems)) ? "disabled=\"disabled\"" : "";
|
||||||
|
$ATT_key = Convert::raw2att($key);
|
||||||
|
|
||||||
$options .= "<li class=\"".$extraClass."\"><input id=\"$itemID\" name=\"$this->name\" type=\"radio\" value=\"$key\"$checked $disabled class=\"radio\" /> <label title=\"$key\" for=\"$itemID\">$value</label></li>\n";
|
$options .= "<li class=\"".$extraClass."\"><input id=\"$itemID\" name=\"$this->name\" type=\"radio\" value=\"$key\"$checked $disabled class=\"radio\" /> <label title=\"$ATT_key\" for=\"$itemID\">$value</label></li>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add "custom" input field
|
// Add "custom" input field
|
||||||
|
@ -47,7 +47,7 @@ class MemberDatetimeOptionsetFieldTest extends SapphireTest {
|
|||||||
$field = $this->createDateFormatFieldForMember($this->objFromFixture('Member', 'noformatmember'));
|
$field = $this->createDateFormatFieldForMember($this->objFromFixture('Member', 'noformatmember'));
|
||||||
$field->setForm(new Form(new MemberDatetimeOptionsetFieldTest_Controller(), 'Form', new FieldSet(), new FieldSet())); // fake form
|
$field->setForm(new Form(new MemberDatetimeOptionsetFieldTest_Controller(), 'Form', new FieldSet(), new FieldSet())); // fake form
|
||||||
$parser = new CSSContentParser($field->Field());
|
$parser = new CSSContentParser($field->Field());
|
||||||
$xmlArr = $parser->getBySelector('#Form_Form_DateFormat_MMMdyyyy');
|
$xmlArr = $parser->getBySelector('#Form_Form_DateFormat_MMM_d__yyyy');
|
||||||
$this->assertEquals('checked', (string) $xmlArr[0]['checked']);
|
$this->assertEquals('checked', (string) $xmlArr[0]['checked']);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ class MemberDatetimeOptionsetFieldTest extends SapphireTest {
|
|||||||
$field = $this->createTimeFormatFieldForMember($this->objFromFixture('Member', 'noformatmember'));
|
$field = $this->createTimeFormatFieldForMember($this->objFromFixture('Member', 'noformatmember'));
|
||||||
$field->setForm(new Form(new MemberDatetimeOptionsetFieldTest_Controller(), 'Form', new FieldSet(), new FieldSet())); // fake form
|
$field->setForm(new Form(new MemberDatetimeOptionsetFieldTest_Controller(), 'Form', new FieldSet(), new FieldSet())); // fake form
|
||||||
$parser = new CSSContentParser($field->Field());
|
$parser = new CSSContentParser($field->Field());
|
||||||
$xmlArr = $parser->getBySelector('#Form_Form_TimeFormat_hmmssa');
|
$xmlArr = $parser->getBySelector('#Form_Form_TimeFormat_h_mm_ss_a');
|
||||||
$this->assertEquals('checked', (string) $xmlArr[0]['checked']);
|
$this->assertEquals('checked', (string) $xmlArr[0]['checked']);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ class MemberDatetimeOptionsetFieldTest extends SapphireTest {
|
|||||||
$field = $this->createDateFormatFieldForMember($member);
|
$field = $this->createDateFormatFieldForMember($member);
|
||||||
$field->setForm(new Form(new MemberDatetimeOptionsetFieldTest_Controller(), 'Form', new FieldSet(), new FieldSet())); // fake form
|
$field->setForm(new Form(new MemberDatetimeOptionsetFieldTest_Controller(), 'Form', new FieldSet(), new FieldSet())); // fake form
|
||||||
$parser = new CSSContentParser($field->Field());
|
$parser = new CSSContentParser($field->Field());
|
||||||
$xmlArr = $parser->getBySelector('#Form_Form_DateFormat_MMddyyyy');
|
$xmlArr = $parser->getBySelector('#Form_Form_DateFormat_MM_dd_yyyy');
|
||||||
$this->assertEquals('checked', (string) $xmlArr[0]['checked']);
|
$this->assertEquals('checked', (string) $xmlArr[0]['checked']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user