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

Form: correctly set type attribute for inputs #1312

parent 2bc52ea3
No related branches found
No related tags found
No related merge requests found
......@@ -23,6 +23,7 @@ class form_checkableelement_test extends DokuWikiTest {
$this->assertEquals('second', pq($inputs->elements[1])->val());
$this->assertEquals('checked', pq($inputs->elements[0])->attr('checked'));
$this->assertEquals('', pq($inputs->elements[1])->attr('checked'));
$this->assertEquals('radio', pq($inputs->elements[0])->attr('type'));
}
/**
......@@ -45,5 +46,6 @@ class form_checkableelement_test extends DokuWikiTest {
$this->assertEquals('second', pq($inputs->elements[1])->val());
$this->assertEquals('', pq($inputs->elements[0])->attr('checked'));
$this->assertEquals('checked', pq($inputs->elements[1])->attr('checked'));
$this->assertEquals('radio', pq($inputs->elements[0])->attr('type'));
}
}
......@@ -14,6 +14,7 @@ class form_inputelement_test extends DokuWikiTest {
$input = $pq->find('input[name=foo]');
$this->assertTrue($input->length == 1);
$this->assertEquals('this is text', $input->val());
$this->assertEquals('text', $input->attr('type'));
$label = $pq->find('label');
$this->assertTrue($label->length == 1);
......@@ -38,4 +39,20 @@ class form_inputelement_test extends DokuWikiTest {
$this->assertEquals('a new text', $input->val());
}
function test_password() {
$form = new Form\Form();
$form->addPasswordInput('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('this is text', $input->val());
$this->assertEquals('password', $input->attr('type'));
$label = $pq->find('label');
$this->assertTrue($label->length == 1);
$this->assertEquals('label text', $label->find('span')->text());
}
}
......@@ -29,6 +29,7 @@ class InputElement extends Element {
public function __construct($type, $name, $label = '') {
parent::__construct($type, array('name' => $name));
$this->attr('name', $name);
$this->attr('type', $type);
if($label) $this->label = new Label($label);
}
......
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