|
|
@@ -7442,4 +7442,63 @@ class FormHelperTest extends TestCase
|
|
|
$this->assertSame($mock, $this->Form->context($mock));
|
|
|
$this->assertSame($mock, $this->Form->context());
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * testAutoDomId
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testAutoDomId()
|
|
|
+ {
|
|
|
+ $result = $this->Form->text('field', ['id' => true]);
|
|
|
+ $expected = [
|
|
|
+ 'input' => ['type' => 'text', 'name' => 'field', 'id' => 'field'],
|
|
|
+ ];
|
|
|
+ $this->assertHtml($expected, $result);
|
|
|
+
|
|
|
+ // Ensure id => doesn't cause problem when multiple inputs are generated.
|
|
|
+ $result = $this->Form->radio('field', ['option A', 'option B'], ['id' => true]);
|
|
|
+ $expected = [
|
|
|
+ 'input' => ['type' => 'hidden', 'name' => 'field', 'value' => ''],
|
|
|
+ ['label' => ['for' => 'field-0']],
|
|
|
+ ['input' => ['type' => 'radio', 'name' => 'field', 'value' => '0', 'id' => 'field-0']],
|
|
|
+ 'option A',
|
|
|
+ '/label',
|
|
|
+ ['label' => ['for' => 'field-1']],
|
|
|
+ ['input' => ['type' => 'radio', 'name' => 'field', 'value' => '1', 'id' => 'field-1']],
|
|
|
+ 'option B',
|
|
|
+ '/label',
|
|
|
+ ];
|
|
|
+ $this->assertHtml($expected, $result);
|
|
|
+
|
|
|
+ $result = $this->Form->select(
|
|
|
+ 'multi_field',
|
|
|
+ ['first', 'second'],
|
|
|
+ ['multiple' => 'checkbox', 'id' => true]
|
|
|
+ );
|
|
|
+ $expected = [
|
|
|
+ 'input' => [
|
|
|
+ 'type' => 'hidden', 'name' => 'multi_field', 'value' => ''
|
|
|
+ ],
|
|
|
+ ['div' => ['class' => 'checkbox']],
|
|
|
+ ['label' => ['for' => 'multi-field-0']],
|
|
|
+ ['input' => [
|
|
|
+ 'type' => 'checkbox', 'name' => 'multi_field[]',
|
|
|
+ 'value' => '0', 'id' => 'multi-field-0'
|
|
|
+ ]],
|
|
|
+ 'first',
|
|
|
+ '/label',
|
|
|
+ '/div',
|
|
|
+ ['div' => ['class' => 'checkbox']],
|
|
|
+ ['label' => ['for' => 'multi-field-1']],
|
|
|
+ ['input' => [
|
|
|
+ 'type' => 'checkbox', 'name' => 'multi_field[]',
|
|
|
+ 'value' => '1', 'id' => 'multi-field-1'
|
|
|
+ ]],
|
|
|
+ 'second',
|
|
|
+ '/label',
|
|
|
+ '/div',
|
|
|
+ ];
|
|
|
+ $this->assertHtml($expected, $result);
|
|
|
+ }
|
|
|
}
|