Skip to content

Commit

Permalink
cosmetic changes for pull request #14
Browse files Browse the repository at this point in the history
  • Loading branch information
czubehead committed Aug 10, 2018
1 parent 684d2c9 commit e072dba
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 42 deletions.
20 changes: 16 additions & 4 deletions docs/Czubehead/BootstrapForms/Inputs/CheckboxInput.html
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@ <h2>Methods</h2>
<a href="#method_makeCheckbox">makeCheckbox</a>(string $name, string $htmlId, string|null
$caption = NULL, bool $checked = FALSE,
bool|mixed $value = FALSE, bool $required =
FALSE, bool $disabled = FALSE)
FALSE, bool $disabled = FALSE,
<abbr title="Nette\Forms\Rules">Rules</abbr>
|null $rules = NULL)

<p>Makes a Bootstrap checkbox HTML</p></div>
<div class="col-md-2"></div>
Expand All @@ -163,7 +165,7 @@ <h2>Details</h2>
<div id="method-details">
<div class="method-item">
<h3 id="method_showValidation">
<div class="location">at line 92</div>
<div class="location">at line 93</div>
<code>
<abbr title="Nette\Utils\Html">Html</abbr>
<strong>showValidation</strong>(
Expand Down Expand Up @@ -209,7 +211,7 @@ <h4>Return Value</h4>
</div>
<div class="method-item">
<h3 id="method_getControl">
<div class="location">at line 33</div>
<div class="location">at line 34</div>
<code>
<abbr title="Nette\Utils\Html">Html</abbr>
<strong>getControl</strong>()
Expand Down Expand Up @@ -245,7 +247,9 @@ <h3 id="method_makeCheckbox">
<abbr title="Nette\Utils\Html">Html</abbr>
<strong>makeCheckbox</strong>(string $name, string $htmlId, string|null $caption = NULL,
bool $checked = FALSE, bool|mixed $value = FALSE, bool $required = FALSE, bool $disabled
= FALSE)
= FALSE,
<abbr title="Nette\Forms\Rules">Rules</abbr>
|null $rules = NULL)
</code>
</h3>
<div class="details">
Expand Down Expand Up @@ -292,6 +296,14 @@ <h4>Parameters</h4>
<td>$disabled</td>
<td></td>
</tr>
<tr>
<td>
<abbr title="Nette\Forms\Rules">Rules</abbr>
|null
</td>
<td>$rules</td>
<td></td>
</tr>
</table>


Expand Down
6 changes: 3 additions & 3 deletions docs/Czubehead/BootstrapForms/Inputs/RadioInput.html
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ <h4>Return Value</h4>
</div>
<div class="method-item">
<h3 id="method_showValidation">
<div class="location">at line 102</div>
<div class="location">at line 107</div>
<code>
<abbr title="Nette\Utils\Html">Html</abbr>
<strong>showValidation</strong>(
Expand Down Expand Up @@ -622,7 +622,7 @@ <h4>Return Value</h4>
</div>
<div class="method-item">
<h3 id="method___construct">
<div class="location">at line 40</div>
<div class="location">at line 41</div>
<code>
<strong>__construct</strong>(string|object $label = NULL, array $items = NULL)
</code>
Expand Down Expand Up @@ -653,7 +653,7 @@ <h4>Parameters</h4>
</div>
<div class="method-item">
<h3 id="method_getControl">
<div class="location">at line 52</div>
<div class="location">at line 53</div>
<code>
<abbr title="Nette\Utils\Html">Html</abbr>
<strong>getControl</strong>()
Expand Down
2 changes: 1 addition & 1 deletion docs/renderer.index
Original file line number Diff line number Diff line change
@@ -1 +1 @@
C:19:"Sami\Renderer\Index":3323:{a:3:{i:0;a:30:{s:43:"Czubehead\BootstrapForms\BootstrapContainer";s:40:"711f6171ddf584e77ac2a20d1649afcd696246d9";s:38:"Czubehead\BootstrapForms\BootstrapForm";s:40:"71d9dd25f472d9f2be791634bec403a5a278c0e2";s:42:"Czubehead\BootstrapForms\BootstrapRenderer";s:40:"970ff45affe799e40814dc60118a4d39ce169fe4";s:39:"Czubehead\BootstrapForms\BootstrapUtils";s:40:"4ed0248a0998ad81e3f0618d1cadf6598ab8266d";s:45:"Czubehead\BootstrapForms\Enums\DateTimeFormat";s:40:"323b7e9e40869b19e66ca73ef9e28706401126cc";s:41:"Czubehead\BootstrapForms\Enums\RenderMode";s:40:"d5f7bc85f6a1419d8299c8de3317d1e22f2435c8";s:45:"Czubehead\BootstrapForms\Enums\RendererConfig";s:40:"76c26e2f89745b24b56a5d916a9a71a33c84e5fa";s:46:"Czubehead\BootstrapForms\Enums\RendererOptions";s:40:"da961d3541b65c99b5e78b381bebc198cee75308";s:43:"Czubehead\BootstrapForms\Grid\BootstrapCell";s:40:"bfe8a9634b1a1c346ebeabff7a09ebac8ed6ecc8";s:42:"Czubehead\BootstrapForms\Grid\BootstrapRow";s:40:"1bc6a3bbcfd144794b763e6aff1b58af0f805d6f";s:43:"Czubehead\BootstrapForms\Inputs\ButtonInput";s:40:"9b166f00d87fd5659b0a032e710b0b5fd3039b8b";s:45:"Czubehead\BootstrapForms\Inputs\CheckboxInput";s:40:"a1c00a3a9033c5b2e2b320ec12cf8d4faa45c2c6";s:49:"Czubehead\BootstrapForms\Inputs\CheckboxListInput";s:40:"be6d380ede10ec029ef9bbfac70ce773d759dd44";s:45:"Czubehead\BootstrapForms\Inputs\DateTimeInput";s:40:"e451ed84f5e007bd0023f9361ae3d14893794ea7";s:50:"Czubehead\BootstrapForms\Inputs\IAutocompleteInput";s:40:"cd891feac830aa5afc8d1165ec04b5e8dd6d5564";s:48:"Czubehead\BootstrapForms\Inputs\IValidationInput";s:40:"2423e628d484c0159e38ea5be94a5a062cd7eed3";s:48:"Czubehead\BootstrapForms\Inputs\MultiselectInput";s:40:"708e030278b4479b40ecc14e982d68e286648874";s:42:"Czubehead\BootstrapForms\Inputs\RadioInput";s:40:"3e6c8a3ec20df4b7fcf2d5020845c11302ed2e94";s:43:"Czubehead\BootstrapForms\Inputs\SelectInput";s:40:"fbf5d22da7473c237cd3aab62605090714fc986e";s:49:"Czubehead\BootstrapForms\Inputs\SubmitButtonInput";s:40:"2c3dcae59aca822234f6b33debc53237c9f15b48";s:45:"Czubehead\BootstrapForms\Inputs\TextAreaInput";s:40:"c6073375d24a64a19321c1a6c4c42d5cf284dead";s:41:"Czubehead\BootstrapForms\Inputs\TextInput";s:40:"3d185e42f9cea09af5ebc750dbc408897c11768c";s:43:"Czubehead\BootstrapForms\Inputs\UploadInput";s:40:"7baaffaca380d4d94dd71a1b8aeefc89a2930145";s:43:"Czubehead\BootstrapForms\Traits\AddRowTrait";s:40:"16caa445cb0196f40ab78ea52ce6038a45310f04";s:52:"Czubehead\BootstrapForms\Traits\BootstrapButtonTrait";s:40:"240e92b93036f83b66f6a7ce0477491407dd2f10";s:55:"Czubehead\BootstrapForms\Traits\BootstrapContainerTrait";s:40:"18ee09cc9f1e299da3d0a02c99a26768ea01d6ff";s:48:"Czubehead\BootstrapForms\Traits\ChoiceInputTrait";s:40:"f7a582670d28121133249824e917d7182f53f0c6";s:48:"Czubehead\BootstrapForms\Traits\FakeControlTrait";s:40:"682bdf6f9c7e6a35a288de23f36edd508e937f6d";s:48:"Czubehead\BootstrapForms\Traits\InputPromptTrait";s:40:"2b7ad77ed72f4d95a6d95c774c6157324b4a5a55";s:55:"Czubehead\BootstrapForms\Traits\StandardValidationTrait";s:40:"9af41b41d39333af4f3dde2c6ce860c24d3d4e64";}i:1;a:1:{i:0;s:6:"master";}i:2;a:6:{i:0;s:9:"Czubehead";i:1;s:24:"Czubehead\BootstrapForms";i:2;s:30:"Czubehead\BootstrapForms\Enums";i:3;s:29:"Czubehead\BootstrapForms\Grid";i:4;s:31:"Czubehead\BootstrapForms\Inputs";i:5;s:31:"Czubehead\BootstrapForms\Traits";}}}
C:19:"Sami\Renderer\Index":3323:{a:3:{i:0;a:30:{s:43:"Czubehead\BootstrapForms\BootstrapContainer";s:40:"711f6171ddf584e77ac2a20d1649afcd696246d9";s:38:"Czubehead\BootstrapForms\BootstrapForm";s:40:"71d9dd25f472d9f2be791634bec403a5a278c0e2";s:42:"Czubehead\BootstrapForms\BootstrapRenderer";s:40:"970ff45affe799e40814dc60118a4d39ce169fe4";s:39:"Czubehead\BootstrapForms\BootstrapUtils";s:40:"4ed0248a0998ad81e3f0618d1cadf6598ab8266d";s:45:"Czubehead\BootstrapForms\Enums\DateTimeFormat";s:40:"323b7e9e40869b19e66ca73ef9e28706401126cc";s:41:"Czubehead\BootstrapForms\Enums\RenderMode";s:40:"d5f7bc85f6a1419d8299c8de3317d1e22f2435c8";s:45:"Czubehead\BootstrapForms\Enums\RendererConfig";s:40:"76c26e2f89745b24b56a5d916a9a71a33c84e5fa";s:46:"Czubehead\BootstrapForms\Enums\RendererOptions";s:40:"da961d3541b65c99b5e78b381bebc198cee75308";s:43:"Czubehead\BootstrapForms\Grid\BootstrapCell";s:40:"bfe8a9634b1a1c346ebeabff7a09ebac8ed6ecc8";s:42:"Czubehead\BootstrapForms\Grid\BootstrapRow";s:40:"1bc6a3bbcfd144794b763e6aff1b58af0f805d6f";s:43:"Czubehead\BootstrapForms\Inputs\ButtonInput";s:40:"9b166f00d87fd5659b0a032e710b0b5fd3039b8b";s:45:"Czubehead\BootstrapForms\Inputs\CheckboxInput";s:40:"b7f2e53fddd9ede4395aea020465483abd300ece";s:49:"Czubehead\BootstrapForms\Inputs\CheckboxListInput";s:40:"f5fad03b6bbfa1576d1ccf0706b12c56e63b3e2c";s:45:"Czubehead\BootstrapForms\Inputs\DateTimeInput";s:40:"e451ed84f5e007bd0023f9361ae3d14893794ea7";s:50:"Czubehead\BootstrapForms\Inputs\IAutocompleteInput";s:40:"cd891feac830aa5afc8d1165ec04b5e8dd6d5564";s:48:"Czubehead\BootstrapForms\Inputs\IValidationInput";s:40:"2423e628d484c0159e38ea5be94a5a062cd7eed3";s:48:"Czubehead\BootstrapForms\Inputs\MultiselectInput";s:40:"708e030278b4479b40ecc14e982d68e286648874";s:42:"Czubehead\BootstrapForms\Inputs\RadioInput";s:40:"4590a80963b9ecaa5962f54ccd1f04da41b7d3a1";s:43:"Czubehead\BootstrapForms\Inputs\SelectInput";s:40:"fbf5d22da7473c237cd3aab62605090714fc986e";s:49:"Czubehead\BootstrapForms\Inputs\SubmitButtonInput";s:40:"2c3dcae59aca822234f6b33debc53237c9f15b48";s:45:"Czubehead\BootstrapForms\Inputs\TextAreaInput";s:40:"c6073375d24a64a19321c1a6c4c42d5cf284dead";s:41:"Czubehead\BootstrapForms\Inputs\TextInput";s:40:"3d185e42f9cea09af5ebc750dbc408897c11768c";s:43:"Czubehead\BootstrapForms\Inputs\UploadInput";s:40:"7baaffaca380d4d94dd71a1b8aeefc89a2930145";s:43:"Czubehead\BootstrapForms\Traits\AddRowTrait";s:40:"16caa445cb0196f40ab78ea52ce6038a45310f04";s:52:"Czubehead\BootstrapForms\Traits\BootstrapButtonTrait";s:40:"240e92b93036f83b66f6a7ce0477491407dd2f10";s:55:"Czubehead\BootstrapForms\Traits\BootstrapContainerTrait";s:40:"18ee09cc9f1e299da3d0a02c99a26768ea01d6ff";s:48:"Czubehead\BootstrapForms\Traits\ChoiceInputTrait";s:40:"f7a582670d28121133249824e917d7182f53f0c6";s:48:"Czubehead\BootstrapForms\Traits\FakeControlTrait";s:40:"682bdf6f9c7e6a35a288de23f36edd508e937f6d";s:48:"Czubehead\BootstrapForms\Traits\InputPromptTrait";s:40:"2b7ad77ed72f4d95a6d95c774c6157324b4a5a55";s:55:"Czubehead\BootstrapForms\Traits\StandardValidationTrait";s:40:"9af41b41d39333af4f3dde2c6ce860c24d3d4e64";}i:1;a:1:{i:0;s:6:"master";}i:2;a:6:{i:0;s:9:"Czubehead";i:1;s:24:"Czubehead\BootstrapForms";i:2;s:30:"Czubehead\BootstrapForms\Enums";i:3;s:29:"Czubehead\BootstrapForms\Grid";i:4;s:31:"Czubehead\BootstrapForms\Inputs";i:5;s:31:"Czubehead\BootstrapForms\Traits";}}}
2 changes: 1 addition & 1 deletion docs/sami.js
Original file line number Diff line number Diff line change
Expand Up @@ -1466,7 +1466,7 @@ window.projectVersion = 'master';
tokens = tokens.concat(term.match(/(([A-Z]?[^A-Z]*)|([a-z]?[^a-z]*))/g).slice(0, -1));

return tokens;
}
};

root.Sami = {
/**
Expand Down
31 changes: 16 additions & 15 deletions src/Inputs/CheckboxInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@ public function getControl()

/**
* Makes a Bootstrap checkbox HTML
* @param string $name
* @param string $htmlId
* @param string|null $caption
* @param bool $checked
* @param bool|mixed $value pass false to omit
* @param bool $required
* @param bool $disabled
* @param string $name
* @param string $htmlId
* @param string|null $caption
* @param bool $checked
* @param bool|mixed $value pass false to omit
* @param bool $required
* @param bool $disabled
* @param Nette\Forms\Rules|null $rules
* @return Html
*/
public static function makeCheckbox(
Expand All @@ -54,14 +55,14 @@ public static function makeCheckbox(
{
$label = Html::el('label', ['class' => ['custom-control', 'custom-checkbox']]);
$input = Html::el('input', [
'type' => 'checkbox',
'class' => ['custom-control-input'],
'name' => $name,
'disabled' => $disabled,
'required' => $required,
'checked' => $checked,
'id' => $htmlId,
'data-nette-rules' => $rules ? Nette\Forms\Helpers::exportRules($rules) : null,
'type' => 'checkbox',
'class' => ['custom-control-input'],
'name' => $name,
'disabled' => $disabled,
'required' => $required,
'checked' => $checked,
'id' => $htmlId,
'data-nette-rules' => $rules ? Nette\Forms\Helpers::exportRules($rules) : FALSE,
]);
if ($value !== FALSE) {
$input->attrs += [
Expand Down
34 changes: 16 additions & 18 deletions src/Inputs/RadioInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
use Czubehead\BootstrapForms\Enums\RendererOptions;
use Czubehead\BootstrapForms\Traits\ChoiceInputTrait;
use Czubehead\BootstrapForms\Traits\StandardValidationTrait;
use Nette;
use Nette\Forms\Controls\ChoiceControl;
use Nette\Forms\Helpers;
use Nette\Utils\Html;


Expand Down Expand Up @@ -68,17 +68,21 @@ public function getControl()
'class' => ['custom-control', 'custom-radio'],
]);

$wrapper->addHtml(
Html::el('input', [
'class' => ['custom-control-input'],
'type' => 'radio',
'value' => $value,
'name' => $this->getHtmlName(),
'checked' => $this->isValueSelected($value),
'disabled' => $disabledOption,
'id' => $itemHtmlId,
])
);
$input = Html::el('input', [
'class' => ['custom-control-input'],
'type' => 'radio',
'value' => $value,
'name' => $this->getHtmlName(),
'checked' => $this->isValueSelected($value),
'disabled' => $disabledOption,
'id' => $itemHtmlId,
]);
if ($c == 0) {
// the first (0th) input has data-nette-rules, none other
$input->setAttribute('data-nette-rules', Helpers::exportRules($this->getRules()));
}

$wrapper->addHtml($input);

$wrapper->addHtml(
Html::el('label', [
Expand All @@ -90,12 +94,6 @@ public function getControl()
$container->addHtml($wrapper);
$c++;
}
if ($this->getRules()) {

$container->getChildren()[0] // wrapper
->getChildren()[0] // input
->setAttribute('data-nette-rules', Nette\Forms\Helpers::exportRules($this->getRules()));
}

return $container;
}
Expand Down

0 comments on commit e072dba

Please sign in to comment.