Skip to content

Commit

Permalink
fix webarchitect609#10: Не показывать пустое значение обязательным полям
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaySuhih committed Jun 30, 2021
1 parent c7f4e72 commit 0e8e71c
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/main/WeekDayType.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,19 @@ public static function getFilterHTML($userField, $htmlControl)
* @return string
*
*/
protected static function getSelectHTML($name, $current = null, $multiple = false)
protected static function getSelectHTML($name, $current = null, $multiple = false, $mandatory = false)
{
if (empty(static::$days)) {
for ($i = WeekDayISO8601::MONDAY; $i <= WeekDayISO8601::SUNDAY; $i++) {
static::$days[$i] = static::getDay($i);
}
}
$return = '<select name="' . $name . '" ' . ($multiple ? 'multiple' : '') . '>';
$return .= '<option></option>';

if (!$multiple && !$mandatory) {
$return .= '<option>(Не выбрано)</option>';
}

foreach (static::$days as $i => $day) {
$selected = false;
if (null !== $current) {
Expand Down Expand Up @@ -188,7 +192,8 @@ public static function getEditFormHTML($userField, $htmlControl)
if ($userField['VALUE_ID'] < 1 && !empty($userField['SETTINGS']['DEFAULT_VALUE'])) {
$htmlControl['VALUE'] = $userField['SETTINGS']['DEFAULT_VALUE'];
}
$return = self::getSelectHTML($userField['FIELD_NAME'], $htmlControl['VALUE']);
$return = self::getSelectHTML($userField['FIELD_NAME'], $htmlControl['VALUE'], false,
'Y' === $userField['MANDATORY']);
} elseif (!empty($htmlControl['VALUE'])) {
$return = static::getAdminListViewHTML($userField, $htmlControl);
}
Expand Down Expand Up @@ -239,7 +244,9 @@ public static function getEditFormHTMLMulty($userField, $htmlControl)
$return = '&nbsp;';
if ($userField['EDIT_IN_LIST'] === 'Y') {
$return = '<table id="table_' . $userField['FIELD_NAME'] . '">
<tr><td>' . self::getSelectHTML($htmlControl['NAME'], $htmlControl['VALUE'], true) . '</td></tr>
<tr><td>' .
self::getSelectHTML($htmlControl['NAME'], $htmlControl['VALUE'], true, 'Y' === $userField['MANDATORY']) .
'</td></tr>
</table>';
} elseif (!empty($htmlControl['VALUE'])) {
$return = static::getAdminListViewHTMLMulty($userField, $htmlControl);
Expand Down

0 comments on commit 0e8e71c

Please sign in to comment.