Skip to content
Snippets Groups Projects
Commit 38c55182 authored by Andreas Gohr's avatar Andreas Gohr
Browse files

form prefill: honor empty values

when a form was submitted with an empty input, that data should still
overwrite the preset value.
parent 8638ead5
No related branches found
No related tags found
No related merge requests found
......@@ -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');
......
......@@ -128,9 +128,7 @@ class InputElement extends Element {
$value = '';
}
}
if($value !== '') {
$this->val($value);
}
$this->val($value);
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment