Skip to content

Commit 1ccb10c

Browse files
authored
Form: add required attribute to select input gui. (#35821) https://mantis.ilias.de/view.php?id=35821 (ILIAS-eLearning#7171)
1 parent 5ff9453 commit 1ccb10c

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

Services/Form/classes/class.ilSelectInputGUI.php

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22

3-
declare(strict_types=1);
4-
53
/**
64
* This file is part of ILIAS, a powerful learning management system
75
* published by ILIAS open source e-Learning e.V.
@@ -18,6 +16,8 @@
1816
*
1917
*********************************************************************/
2018

19+
declare(strict_types=1);
20+
2121
/**
2222
* This class represents a selection list property in a property form.
2323
*
@@ -150,6 +150,12 @@ public function render($a_mode = ""): string
150150
$tpl->parseCurrentBlock();
151151
}
152152

153+
if ($this->getRequired()) {
154+
$tpl->setCurrentBlock('required_attribute');
155+
$tpl->setVariable('REQUIRED', 'required');
156+
$tpl->parseCurrentBlock();
157+
}
158+
153159
// determine value to select. Due to accessibility reasons we
154160
// should always select a value (per default the first one)
155161
$first = true;

Services/Form/templates/default/tpl.prop_select.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!-- BEGIN inline_in_bl -->
22
<div class="form-inline">
33
<!-- END inline_in_bl -->
4-
<select aria-label="{ARIA_LABEL}" class="form-control" id="{ID}" name="{POST_VAR}" <!-- BEGIN cust_attr -->{CUSTOM_ATTR}<!-- END cust_attr --> {DISABLED}>
4+
<select aria-label="{ARIA_LABEL}" class="form-control" id="{ID}" name="{POST_VAR}" <!-- BEGIN cust_attr -->{CUSTOM_ATTR}<!-- END cust_attr --> {DISABLED} <!-- BEGIN required_attribute --> required="{REQUIRED}" <!-- END required_attribute -->>
55
<!-- BEGIN prop_select_option -->
66
<option value="{VAL_SELECT_OPTION}" {CHK_SEL_OPTION}>{TXT_SELECT_OPTION}</option>
77
<!-- END prop_select_option -->

0 commit comments

Comments
 (0)