public function testHelp() { $text1 = Former::text('foo')->inlineHelp('bar')->__toString(); $text2 = Former::text('foo')->blockHelp('bar')->__toString(); $matcher = '<div><label for="foo">Foo</label><input type="text" name="foo" id="foo"><small>Bar</small></div>'; $this->assertEquals($matcher, $text1); $this->assertEquals($matcher, $text2); }
public function testCanInlineASingleField() { $input = Former::text('foo')->raw()->__toString(); $matcher = '<input type="text" name="foo">'; $this->assertEquals($matcher, $input); }
public function testDatalistCustomList() { $datalist = Former::text('foo')->list('bar')->useDatalist(array('foo' => 'bar', 'kel' => 'tar'))->__toString(); $matcher = '<div class="control-group">' . '<label for="foo" class="control-label">Foo</label>' . '<div class="controls">' . '<input list="bar" type="text" name="foo" id="foo">' . '<datalist id="bar">' . '<option value="bar">foo</option>' . '<option value="tar">kel</option>' . '</datalist>' . '</div>' . '</div>'; $this->assertEquals($matcher, $datalist); }
public function testAddClass() { $static = Former::text('foo')->class('foo')->addClass('bar')->__toString(); $input = Former::text('foo', null, null, array('class' => 'foo'))->addClass('bar')->__toString(); $matcher = $this->cg('<input class="foo bar" type="text" name="foo" id="foo">'); $this->assertEquals($matcher, $input); $this->assertEquals($matcher, $static); }
public function testAllTheThings() { $control = Former::text('foo')->state('error')->inlineHelp('foo')->blockHelp('bar')->prepend('@', '$', Button::normal('foo'))->append('@', '$', Button::normal('foo'))->__toString(); $matcher = '<div class="control-group error">' . '<label for="foo" class="control-label">Foo</label>' . '<div class="controls">' . '<div class="input-prepend input-append">' . '<span class="add-on">@</span>' . '<span class="add-on">$</span>' . '<button type="button" class="btn">foo</button>' . '<input type="text" name="foo" id="foo">' . '<span class="add-on">@</span>' . '<span class="add-on">$</span>' . '<button type="button" class="btn">foo</button>' . '</div>' . '<span class="help-inline">Foo</span>' . '<p class="help-block">Bar</p>' . '</div>' . '</div>'; $this->assertEquals($matcher, $control); }
public function testCanChainRulesToForm() { $open = Former::open('#')->rules(array())->addClass('foo')->__toString(); $open .= Former::text('foo')->__toString(); $matcher = $this->createMatcher('form-horizontal foo') . $this->cg(); $this->assertEquals($matcher, $open); }
public function testDoesntUseTranslationsArraysAsLabels() { $input = Former::text('pagination')->__toString(); $matcher = $this->cg('<input type="text" name="pagination" id="pagination">', '<label for="pagination" class="control-label">Pagination</label>'); $this->assertEquals($matcher, $input); }
public function testDisablingValidation() { Former::config('live_validation', false); Former::withRules(array('foo' => 'required')); $input = Former::text('foo')->__toString(); $matcher = $this->cg($this->field(), '<label for="foo" class="control-label">Foo</label>'); $this->assertEquals($matcher, $input); }