Skip to content

Commit

Permalink
Merge pull request #1744 from Admidio/fix-hidden-datetime-fields-not-…
Browse files Browse the repository at this point in the history
…popssible
  • Loading branch information
MightyMCoder authored Jan 29, 2025
2 parents b5695a7 + ac4e503 commit c0a806d
Showing 1 changed file with 43 additions and 21 deletions.
64 changes: 43 additions & 21 deletions adm_program/system/classes/HtmlForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -706,27 +706,6 @@ public function addInput(string $id, string $label, string $value, array $option
break;
}

// set field properties
switch ($optionsAll['property']) {
case self::FIELD_DISABLED:
$attributes['disabled'] = 'disabled';
break;

case self::FIELD_READONLY:
$attributes['readonly'] = 'readonly';
break;

case self::FIELD_REQUIRED:
$attributes['required'] = 'required';
$this->flagRequiredFields = true;
break;

case self::FIELD_HIDDEN:
$attributes['hidden'] = 'hidden';
$attributes['class'] .= ' invisible';
break;
}

// set specific css class for this field
if ($optionsAll['class'] !== '') {
$attributes['class'] .= ' '.$optionsAll['class'];
Expand Down Expand Up @@ -768,6 +747,49 @@ public function addInput(string $id, string $label, string $value, array $option
$value = $datetime->format('H:i');
}

// set field properties
switch ($optionsAll['property']) {
case self::FIELD_DISABLED:
if ($optionsAll['type'] === 'datetime') {
$attributes['dateValueAttributes']['disabled'] = 'disabled';
$attributes['timeValueAttributes']['disabled'] = 'disabled';
} else {
$attributes['disabled'] = 'disabled';
}
break;

case self::FIELD_READONLY:
if ($optionsAll['type'] === 'datetime') {
$attributes['dateValueAttributes']['readonly'] = 'readonly';
$attributes['timeValueAttributes']['readonly'] = 'readonly';
} else {
$attributes['readonly'] = 'readonly';
}
break;

case self::FIELD_REQUIRED:
if ($optionsAll['type'] === 'datetime') {
$attributes['dateValueAttributes']['required'] = 'required';
$attributes['timeValueAttributes']['required'] = 'required';
} else {
$attributes['required'] = 'required';
}
$this->flagRequiredFields = true;
break;

case self::FIELD_HIDDEN:
if ($optionsAll['type'] === 'datetime') {
$attributes['dateValueAttributes']['hidden'] = 'hidden';
$attributes['dateValueAttributes']['class'] .= ' invisible';
$attributes['timeValueAttributes']['hidden'] = 'hidden';
$attributes['timeValueAttributes']['class'] .= ' invisible';
} else {
$attributes['hidden'] = 'hidden';
$attributes['class'] .= ' invisible';
}
break;
}

if ($optionsAll['passwordStrength']) {
$passwordStrengthLevel = 1;
if ($gSettingsManager instanceof SettingsManager && $gSettingsManager->getInt('password_min_strength')) {
Expand Down

0 comments on commit c0a806d

Please sign in to comment.