Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 18 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| Validators | |
0.00% |
0 / 18 |
|
0.00% |
0 / 2 |
30 | |
0.00% |
0 / 1 |
| render | |
0.00% |
0 / 17 |
|
0.00% |
0 / 1 |
20 | |||
| renderOptionLabel | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; under version 2 |
| 7 | * of the License (non-upgradable). |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | * |
| 18 | * Copyright (c) 2015-2022 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | declare(strict_types=1); |
| 23 | |
| 24 | namespace oat\tao\helpers\form\elements\xhtml; |
| 25 | |
| 26 | use oat\tao\helpers\form\elements\Validators as AbstractValidators; |
| 27 | |
| 28 | /** |
| 29 | * Based on tao_helpers_form_elements_xhtml_Radiobox |
| 30 | */ |
| 31 | class Validators extends AbstractValidators |
| 32 | { |
| 33 | use XhtmlRenderingTrait; |
| 34 | |
| 35 | /** |
| 36 | * @see tao_helpers_form_FormElement::render |
| 37 | */ |
| 38 | public function render() |
| 39 | { |
| 40 | $returnValue = $this->renderLabel(); |
| 41 | |
| 42 | $i = 0; |
| 43 | $returnValue .= '<div class="form_radlst form_checklst">'; |
| 44 | foreach ($this->getOptions() as $optionId => $optionLabel) { |
| 45 | $returnValue .= "<input type='checkbox' value='{$optionId}' name='{$this->name}[]' " |
| 46 | . "id='{$this->name}_{$i}' "; |
| 47 | $returnValue .= $this->renderAttributes(); |
| 48 | |
| 49 | if (in_array($optionId, $this->values, true)) { |
| 50 | $returnValue .= " checked='checked' "; |
| 51 | } |
| 52 | |
| 53 | if (in_array($optionId, $this->getDisabledValues(), true)) { |
| 54 | $returnValue .= ' disabled '; |
| 55 | } |
| 56 | |
| 57 | $returnValue .= " /> <label class='elt_desc' for='{$this->name}_{$i}'>"; |
| 58 | $returnValue .= $this->renderOptionLabel($optionId, $optionLabel); |
| 59 | $returnValue .= "</label><br />"; |
| 60 | |
| 61 | $i++; |
| 62 | } |
| 63 | $returnValue .= "</div>"; |
| 64 | |
| 65 | return $returnValue; |
| 66 | } |
| 67 | |
| 68 | protected function renderOptionLabel(string $optionId, string $label): string |
| 69 | { |
| 70 | return $this->getOptionValidatorName($optionId) ?? _dh($label); |
| 71 | } |
| 72 | } |