diff --git a/_test/tests/inc/form/inputelement.test.php b/_test/tests/inc/form/inputelement.test.php index 3257d2a892a0ef700e6eec138c15633f12c01aa4..38e4e832c870402e54397b9f6e513c8db8dcb261 100644 --- a/_test/tests/inc/form/inputelement.test.php +++ b/_test/tests/inc/form/inputelement.test.php @@ -39,6 +39,22 @@ class form_inputelement_test extends DokuWikiTest { $this->assertEquals('a new text', $input->val()); } + function test_prefill_empty() { + global $INPUT; + $INPUT->post->set('foo', ''); + + $form = new Form\Form(); + $form->addTextInput('foo', 'label text')->val('this is text'); + + $html = $form->toHTML(); + $pq = phpQuery::newDocumentXHTML($html); + + $input = $pq->find('input[name=foo]'); + $this->assertTrue($input->length == 1); + $this->assertEquals('', $input->val()); + } + + function test_password() { $form = new Form\Form(); $form->addPasswordInput('foo', 'label text')->val('this is text'); diff --git a/inc/Form/InputElement.php b/inc/Form/InputElement.php index 694dd0848de543a00da945761d9c155089fca161..0242b617975386640d79ee9eb20fe8f20aa8b1d9 100644 --- a/inc/Form/InputElement.php +++ b/inc/Form/InputElement.php @@ -128,9 +128,7 @@ class InputElement extends Element { $value = ''; } } - if($value !== '') { - $this->val($value); - } + $this->val($value); } /**