Skip to content

Commit d1525ac

Browse files
Copilotneilime
andcommitted
fix: render date fields with bootstrap input helper
Agent-Logs-Url: https://github.com/neilime/twbs-helper-module/sessions/89066bf4-771f-46ec-99ab-188ad18b8d01 Co-authored-by: neilime <314088+neilime@users.noreply.github.com>
1 parent 190a95b commit d1525ac

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

config/module.config.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@
112112
'formFile' => \TwbsHelper\Form\View\Helper\FormFile::class,
113113
'forminput' => \TwbsHelper\Form\View\Helper\FormInput::class,
114114
'formInput' => \TwbsHelper\Form\View\Helper\FormInput::class,
115+
'formdate' => \TwbsHelper\Form\View\Helper\FormInput::class,
116+
'formDate' => \TwbsHelper\Form\View\Helper\FormInput::class,
115117
'formsearch' => \TwbsHelper\Form\View\Helper\FormSearch::class,
116118
'formSearch' => \TwbsHelper\Form\View\Helper\FormSearch::class,
117119
'formtext' => \TwbsHelper\Form\View\Helper\FormText::class,

tests/TestSuite/TwbsHelper/Form/View/Helper/FormElementTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace TestSuite\TwbsHelper\Form\View\Helper;
44

5+
use Laminas\Form\Element\Date;
56
use Laminas\Form\Element\Email;
67
use Laminas\Form\Form;
78
use Laminas\View\Renderer\PhpRenderer;
@@ -56,4 +57,26 @@ public function testRenderElement()
5657
'<input class="form-control" maxlength="254" name="email" type="email" value=""/>'
5758
);
5859
}
60+
61+
public function testRenderDateElementWithValue(): void
62+
{
63+
$this->form->add([
64+
'name' => 'createdDate',
65+
'type' => Date::class,
66+
'options' => [
67+
'label' => 'Erfassungsdatum',
68+
'format' => 'Y-m-d',
69+
],
70+
'attributes' => [
71+
'value' => '2026-05-14',
72+
],
73+
]);
74+
75+
$element = $this->form->get('createdDate');
76+
77+
$this->assertSame(
78+
'<input class="form-control" name="createdDate" type="date" value="2026-05-14"/>',
79+
$this->formElementHelper->render($element)
80+
);
81+
}
5982
}

0 commit comments

Comments
 (0)