Skip to content

Commit

Permalink
add checkboxDiv option and modified sample, test case
Browse files Browse the repository at this point in the history
  • Loading branch information
slywalker committed Jun 27, 2013
1 parent 0e2d3e3 commit efc3959
Show file tree
Hide file tree
Showing 4 changed files with 162 additions and 98 deletions.
37 changes: 37 additions & 0 deletions Test/Case/View/Helper/BoostCakeFormHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,43 @@ public function testBeforeInputAfterInput() {

public function testCheckbox() {
$result = $this->Form->input('name', array('type' => 'checkbox'));
$this->assertTags($result, array(
array('div' => array()),
array('div' => array('class' => 'input checkbox')),
array('div' => array('class' => 'checkbox')),
array('input' => array('type' => 'hidden', 'name' => 'data[name]', 'id' => 'name_', 'value' => '0')),
'label' => array('for' => 'name'),
array('input' => array('name' => 'data[name]', 'type' => 'checkbox', 'value' => '1', 'id' => 'name')),
' Name',
'/label',
'/div',
'/div',
'/div'
));

$result = $this->Form->input('name', array(
'type' => 'checkbox',
'before' => '<label>Name</label>',
'label' => false
));
$this->assertTags($result, array(
array('div' => array()),
array('label' => array()),
'Name',
'/label',
array('div' => array('class' => 'input checkbox')),
array('div' => array('class' => 'checkbox')),
array('input' => array('type' => 'hidden', 'name' => 'data[name]', 'id' => 'name_', 'value' => '0')),
array('input' => array('name' => 'data[name]', 'type' => 'checkbox', 'value' => '1', 'id' => 'name')),
'/div',
'/div',
'/div'
));

$result = $this->Form->input('name', array(
'type' => 'checkbox',
'checkboxDiv' => false
));
$this->assertTags($result, array(
array('div' => array()),
array('div' => array('class' => 'input checkbox')),
Expand Down
90 changes: 48 additions & 42 deletions View/BoostCake/bootstrap2.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@
'after' => '<span class="help-block">Example block-level help text here.</span>'
)); ?>
<?php echo $this->Form->input('checkbox', array(
'label' => array(
'text' => 'Check me out',
'class' => 'checkbox'
)
'label' => 'Check me out'
)); ?>
<?php echo $this->Form->submit('Submit', array(
'div' => false,
Expand All @@ -63,10 +60,7 @@ echo h("<?php echo \$this->Form->create('BoostCake', array(
'after' => '<span class=\"help-block\">Example block-level help text here.</span>'
)); ?>
<?php echo \$this->Form->input('checkbox', array(
'label' => array(
'text' => 'Check me out',
'class' => 'checkbox'
)
'label' => 'Check me out'
)); ?>
<?php echo \$this->Form->submit('Submit', array(
'div' => false,
Expand Down Expand Up @@ -140,7 +134,8 @@ echo h("<?php echo \$this->Form->create('BoostCake', array(
'label' => array(
'text' => 'Remember me',
'class' => 'checkbox'
)
),
'checkboxDiv' => false
)); ?>
<?php echo $this->Form->submit('Sign in', array(
'div' => false,
Expand Down Expand Up @@ -169,7 +164,8 @@ echo h("<?php echo \$this->Form->create('BoostCake', array(
'label' => array(
'text' => 'Remember me',
'class' => 'checkbox'
)
),
'checkboxDiv' => false
)); ?>
<?php echo \$this->Form->submit('Sign in', array(
'div' => false,
Expand Down Expand Up @@ -208,10 +204,7 @@ echo h("<?php echo \$this->Form->create('BoostCake', array(
'placeholder' => 'Password'
)); ?>
<?php echo $this->Form->input('remember', array(
'label' => array(
'text' => 'Remember me',
'class' => 'checkbox'
),
'label' => 'Remember me',
'afterInput' => $this->Form->submit('Sign in', array(
'class' => 'btn'
))
Expand All @@ -236,10 +229,7 @@ echo h("<?php echo \$this->Form->create('BoostCake', array(
'placeholder' => 'Password'
)); ?>
<?php echo \$this->Form->input('remember', array(
'label' => array(
'text' => 'Remember me',
'class' => 'checkbox'
),
'label' => 'Remember me',
'afterInput' => \$this->Form->submit('Sign in', array(
'class' => 'btn'
))
Expand Down Expand Up @@ -296,18 +286,15 @@ echo h("<?php echo \$this->Form->create('BoostCake', array(
)
)
)); ?>
<div class="control-group<?php if ($this->Form->isFieldError('radio')): ?> error<?php endif ?>">
<label class="control-label">Radio</label>
<?php echo $this->Form->input('radio', array(
'type' => 'radio',
'div' => false,
'legend' => false,
'options' => array(
1 => 'Option one is this and that—be sure to include why it\'s great',
2 => 'Option two can be something else and selecting it will deselect option one'
)
)); ?>
</div>
<?php echo $this->Form->input('radio', array(
'type' => 'radio',
'before' => '<label class="control-label">Radio</label>',
'legend' => false,
'options' => array(
1 => 'Option one is this and that—be sure to include why it\'s great',
2 => 'Option two can be something else and selecting it will deselect option one'
)
)); ?>
<?php echo $this->Form->input('username', array(
'placeholder' => 'Username',
'div' => 'control-group input-prepend',
Expand Down Expand Up @@ -338,6 +325,17 @@ echo h("<?php echo \$this->Form->create('BoostCake', array(
'placeholder' => 'Password',
'errorMessage' => false
)); ?>
<?php echo $this->Form->input('checkbox', array(
'label' => array('class' => null),
'afterInput' => '<span class="help-block">Checkbox Bootstrap Style</span>'
)); ?>
<?php echo $this->Form->input('checkbox', array(
'div' => false,
'label' => false,
'before' => '<label class="control-label">Checkbox</label>',
'wrapInput' => 'controls',
'afterInput' => '<span class="help-block">Checkbox CakePHP Style</span>'
)); ?>
<div class="form-actions">
<?php echo $this->Form->submit('Save changes', array(
'div' => false,
Expand Down Expand Up @@ -391,18 +389,15 @@ echo h("<?php echo \$this->Form->create('BoostCake', array(
)
)
)); ?>
<div class=\"control-group<?php if (\$this->Form->isFieldError('radio')): ?> error<?php endif ?>\">
<label class=\"control-label\">Radio</label>
<?php echo \$this->Form->input('radio', array(
'type' => 'radio',
'div' => false,
'legend' => false,
'options' => array(
1 => 'Option one is this and that—be sure to include why it\'s great',
2 => 'Option two can be something else and selecting it will deselect option one'
)
)); ?>
</div>
<?php echo \$this->Form->input('radio', array(
'type' => 'radio',
'before' => '<label class=\"control-label\">Radio</label>',
'legend' => false,
'options' => array(
1 => 'Option one is this and that—be sure to include why it\'s great',
2 => 'Option two can be something else and selecting it will deselect option one'
)
)); ?>
<?php echo \$this->Form->input('username', array(
'placeholder' => 'Username',
'div' => 'control-group input-prepend',
Expand Down Expand Up @@ -433,6 +428,17 @@ echo h("<?php echo \$this->Form->create('BoostCake', array(
'placeholder' => 'Password',
'errorMessage' => false
)); ?>
<?php echo \$this->Form->input('checkbox', array(
'label' => array('class' => null),
'afterInput' => '<span class=\"help-block\">Checkbox Bootstrap Style</span>'
)); ?>
<?php echo \$this->Form->input('checkbox', array(
'div' => false,
'label' => false,
'before' => '<label class=\"control-label\">Checkbox</label>',
'wrapInput' => 'controls',
'afterInput' => '<span class=\"help-block\">Checkbox CakePHP Style</span>'
)); ?>
<div class=\"form-actions\">
<?php echo \$this->Form->submit('Save changes', array(
'div' => false,
Expand Down
Loading

0 comments on commit efc3959

Please sign in to comment.