Skip to content

Commit

Permalink
required field fix for nameDiv and infoDiv. Take fieldOptions into co…
Browse files Browse the repository at this point in the history
…nsideration.
  • Loading branch information
Ioannis committed Apr 28, 2024
1 parent d850be8 commit c109a53
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/src/View/Helper/FieeldHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,12 @@ public function formField(string $fieldName,
$fieldArgs = $fieldOptions ?? [];
$fieldArgs['label'] = $fieldOptions['label'] ?? false;
$fieldArgs['readonly'] = !$this->editable
|| (isset($fieldOptions['readonly']) && $fieldOptions['readonly'])
|| \boolval($fieldOptions['readonly'])
|| ($fieldName == 'plugin' && $this->action == 'edit');

// Selects, Checkboxes, and Radio Buttons use "disabled"
$fieldArgs['disabled'] = $fieldArgs['readonly'];
$fieldArgs['required'] = $this->isReqField($fieldName);
$fieldArgs['required'] = $this->isReqField($fieldName) ?? boolval($fieldOptions['required']);

// Get the field type from the map of fields (e.g. 'boolean', 'string', 'timestamp')
$fieldType = $fieldType ?? $this->getFieldType($fieldName);
Expand Down
9 changes: 8 additions & 1 deletion app/templates/element/form/nameDiv.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
[$label, $desc] = $this->Fieeld->calculateLabelAndDescription($fn);
$label = $vv_field_arguments['fieldLabel'] ?? $label;

// Override the default required behavior is the field has the required
// option set
$optionsRequired = boolval($vv_field_arguments['fieldOptions']['required']);

// Extra class required for the grouped controls elements
if(isset($groupedControls)) {
$classes .= 'align-top ';
Expand All @@ -78,7 +82,10 @@
<?php endif; ?>
<?php
// Required Field
if($this->Fieeld->isEditable() && $this->Fieeld->isReqField($fn)) {
if($this->Fieeld->isEditable()
&&
($this->Fieeld->isReqField($fn) || $optionsRequired)
) {
print $this->element('form/requiredSpan');
}
?>
Expand Down
4 changes: 2 additions & 2 deletions app/templates/element/notify/banner.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@

declare(strict_types = 1);

// Params required:
// $info
// Parameters:
// $info: String, required

?>

Expand Down

0 comments on commit c109a53

Please sign in to comment.