function it_can_be_given_contents_as_an_array(Form $form) { $form->label('first', 'First')->willReturn('label1'); $form->checkbox('first', 'First')->willReturn('checkbox1'); $form->label('second', 'Second')->willReturn('label2'); $form->checkbox('second', 'Second')->willReturn('checkbox2'); $this->withContents([['label' => ['first', 'First'], 'input' => ['type' => 'checkbox', 'first', 'First']], ['label' => ['second', 'Second'], 'input' => ['type' => 'checkbox', 'second', 'Second']]])->render()->shouldBe("<div class='form-group'>label1 checkbox1<br />label2 checkbox2<br /></div>"); }
/** * @dataProvider displaytypes */ public function testControlGroupFull($displaytype) { $class = $displaytype; if ($displaytype != '') { $class = ' ' . $displaytype; } // Had to match label and go up to the parent // than back down to get the other elements. Odd but can't // figure out how to find 3 different child elements $matcher = array('tag' => 'div', 'attributes' => array('class' => 'controls'), 'child' => array('tag' => 'input', 'attributes' => array('type' => 'text', 'name' => 'inputfoo', 'id' => 'inputfoo')), 'parent' => array('tag' => 'div', 'attributes' => array('class' => 'control-group' . $class), 'child' => array('tag' => 'label', 'attributes' => array('class' => 'control-label', 'for' => 'inputfoo'), 'content' => 'foo'), 'descendant' => array('tag' => 'div', 'attributes' => array('class' => 'controls'), 'child' => array('tag' => 'input', 'attributes' => array('type' => 'text', 'name' => 'inputfoo', 'id' => 'inputfoo'))))); $html = Form::control_group(Form::label('inputfoo', 'foo'), Form::text('inputfoo'), $displaytype, Form::block_help('You foobared that!')); $this->assertTag($matcher, $html); }
/** * Create a form label element. * * @param string $name The name of the object this label will be * attached to * @param string|null $value The text of the label * @param array $options The options of the label * @return string * @param string $name * @param string $value * @param array $options * @return string * @static */ public static function label($name, $value = null, $options = array()) { return \Bootstrapper\Form::label($name, $value, $options); }
public function testCreateFullControlGroupWithOffsets() { $matcher = array( 'tag' => 'div', 'attributes' => array('class' => 'col-sm-2'), 'child' => array( 'tag' => 'label', 'attributes' => array('for' => 'inputfoo'), 'content' => 'foo', ), 'parent' => array( 'tag' => 'div', 'attributes' => array('class' => 'form-group'), 'child' => array( 'tag' => 'div', 'attributes' => array('class' => 'col-sm-10'), 'child' => array( 'tag' => 'input', 'attributes' => array( 'type' => 'text', 'name' => 'inputfoo', 'id' => 'inputfoo', 'class' => 'form-control' ), ), 'descendant' => array( 'tag' => 'span', 'attributes' => array( 'class' => 'help-block' ), 'content' => 'You foobared that!', ), ), ), ); $html = Form::control_group( Form::label('inputfoo', 'foo'), Form::text('inputfoo'), null, Form::block_help('You foobared that!'), 2 ); $this->assertHTML($matcher, $html); }