• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

contributte / forms-bootstrap / #71

22 Apr 2024 10:51AM UTC coverage: 83.039%. Remained the same
#71

Pull #95

github

dakorpar
compativility with nette forms 3.2.2
Pull Request #95: Nette forms3.2.2

705 of 849 relevant lines covered (83.04%)

5.64 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

76.92
/src/Inputs/CheckboxListInput.php
1
<?php declare(strict_types = 1);
2

3
namespace Contributte\FormsBootstrap\Inputs;
4

5
use Contributte\FormsBootstrap\Traits\ChoiceInputTrait;
6
use Contributte\FormsBootstrap\Traits\StandardValidationTrait;
7
use Nette\Forms\Controls\CheckboxList;
8
use Nette\Utils\Html;
9

10
/**
11
 * Class CheckboxListInput.
12
 * Multiple checkboxes in a list.
13
 */
14
class CheckboxListInput extends CheckboxList implements IValidationInput
15
{
16

17
        use ChoiceInputTrait;
18
        use StandardValidationTrait {
19
                showValidation as protected _rawShowValidation;
20
        }
21

22
        /**
23
         * @inheritdoc
24
         */
25
        public function getControl(): Html
26
        {
27
                parent::getControl();
2✔
28

29
                $fieldset = Html::el('fieldset', [
2✔
30
                        'disabled' => $this->isControlDisabled(),
2✔
31
                ]);
2✔
32

33
                $baseId = $this->getHtmlId();
2✔
34
                $c = 0;
2✔
35
                foreach ($this->items as $value => $caption) {
2✔
36
                        $line = CheckboxInput::makeCheckbox(
2✔
37
                                $this->getHtmlName(),
2✔
38
                                $baseId . $c,
2✔
39
                                $caption === null ? null : (string) $caption,
2✔
40
                                $this->isValueSelected($value),
2✔
41
                                $value,
2✔
42
                                false,
2✔
43
                                $this->isValueDisabled($value),
2✔
44
                                $this->getRules()
2✔
45
                        );
2✔
46

47
                        $fieldset->addHtml($line);
2✔
48
                        $c++;
2✔
49
                }
50

51
                return $fieldset;
2✔
52
        }
53

54
        /**
55
         * Modify control in such a way that it explicitly shows its validation state.
56
         * Returns the modified element.
57
         */
58
        public function showValidation(Html $control): Html
59
        {
60
                // same parent, but no children
61
                $fieldset = Html::el($control->getName(), $control->attrs);
×
62
                /** @var Html $label */
63
                foreach ($control->getChildren() as $label) {
×
64
                        $input = $label->getChildren()[0];
×
65
                        $label->getChildren()[0] = $this->_rawShowValidation($input);
×
66
                        $fieldset->addHtml($label);
×
67
                }
68

69
                return $fieldset;
×
70
        }
71

72
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc