19 declare(strict_types=1);
35 string $a_postvar =
"" 39 $this->
lng = $DIC->language();
41 $this->
setType(
"checkboxgroup");
49 $this->use_values_as_keys = $a_val;
62 $this->options[] = $a_option;
72 foreach ($a_options as $key => $label) {
73 if (is_string($label)) {
75 $this->options[] = $chb;
77 $this->options[] = $label;
87 public function setValue(?array $a_value): void
89 $this->value = $a_value;
101 foreach ($option->getSubItems() as $item) {
102 $item->setValueByArray($a_values);
112 if ($this->
getRequired() && count($values) === 0) {
119 foreach ($option->getSubItems() as $item) {
120 $item_ok = $item->checkInput();
121 if (!$item_ok && in_array($option->getValue(), $values)) {
148 foreach ($option->getSubItems() as $item) {
149 if ($item->getType() !=
"section_header") {
150 $ret = $item->getItemByPostVar($a_post_var);
151 if (is_object($ret)) {
168 return $this->
render(
'toolbar');
171 protected function render($a_mode =
''): string
173 $tpl =
new ilTemplate(
"tpl.prop_checkbox_group.html",
true,
true,
"components/ILIAS/Form");
177 if ($option->getInfo() !=
"") {
178 $tpl->setCurrentBlock(
"checkbox_option_desc");
179 $tpl->setVariable(
"CHECKBOX_OPTION_DESC", $option->getInfo());
180 $tpl->parseCurrentBlock();
184 if (count($option->getSubItems()) > 0) {
185 $tpl->setCurrentBlock(
"checkbox_option_subform");
187 $pf->setMode(
"subform");
188 $pf->setItems($option->getSubItems());
189 $tpl->setVariable(
"SUB_FORM", $pf->getContent());
190 $tpl->setVariable(
"SOP_ID", $this->
getFieldId() .
"_" . $option->getValue());
191 if ($pf->getMultipart()) {
194 $tpl->parseCurrentBlock();
195 if ($pf->getMultipart()) {
200 $tpl->setCurrentBlock(
"prop_checkbox_option");
203 $tpl->setVariable(
"POST_VAR", $this->
getPostVar() .
'[]');
204 $tpl->setVariable(
"VAL_CHECKBOX_OPTION", $option->getValue());
206 $tpl->setVariable(
"POST_VAR", $this->
getPostVar() .
'[' . $option->getValue() .
']');
207 $tpl->setVariable(
"VAL_CHECKBOX_OPTION",
"1");
210 $tpl->setVariable(
"OP_ID", $this->
getFieldId() .
"_" . $option->getValue());
211 $tpl->setVariable(
"FID", $this->
getFieldId());
213 if ($this->
getDisabled() or $option->getDisabled()) {
214 $tpl->setVariable(
'DISABLED',
'disabled="disabled" ');
219 if (in_array($option->getValue(), $this->
getValue())) {
221 "CHK_CHECKBOX_OPTION",
227 if (isset($cval[$option->getValue()]) && $cval[$option->getValue()] == 1) {
229 "CHK_CHECKBOX_OPTION",
235 $tpl->setVariable(
"TXT_CHECKBOX_OPTION", $option->getTitle());
238 $tpl->parseCurrentBlock();
247 $subInputItems = parent::getSubInputItemsRecursive();
252 $subInputItems = array_merge($subInputItems, $option->getSubInputItemsRecursive());
255 return $subInputItems;
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
setVariable($variable, $value='')
Sets a variable value.
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
__construct(Container $dic, ilPlugin $plugin)