mirror of
https://github.com/processwire/processwire.git
synced 2025-08-23 06:44:38 +02:00
Make Inputfield requiredLabel customizable per field from API via $inputfield->requiredLabel property, to provide option to override default "missing requird value" label.
This commit is contained in:
@@ -51,6 +51,7 @@
|
||||
* @property string $description Optional description that appears under label to provide more detailed information. #pw-group-labels
|
||||
* @property string $notes Optional notes that appear under input area to provide additional notes. #pw-group-labels
|
||||
* @property string $icon Optional font-awesome icon name to accompany label (excluding the "fa-") part). #pw-group-labels
|
||||
* @property string $requiredLabel Optional custom label to display when missing required value. @since 3.0.98 #pw-group-labels
|
||||
* @property string $head Optional text that appears below label but above description (only used by some Inputfields). #pw-internal
|
||||
* @property string|null $prependMarkup Optional markup to prepend to the Inputfield content container. #pw-group-other
|
||||
* @property string|null $appendMarkup Optional markup to append to the Inputfield content container. #pw-group-other
|
||||
|
@@ -795,7 +795,9 @@ class InputfieldWrapper extends Inputfield implements \Countable, \IteratorAggre
|
||||
|
||||
// check if a value is required and field is empty, trigger an error if so
|
||||
if($child->name && $child->getSetting('required') && $child->isEmpty()) {
|
||||
$child->error($this->requiredLabel);
|
||||
$requiredLabel = $child->getSetting('requiredLabel');
|
||||
if(empty($requiredLabel)) $requiredLabel = $this->requiredLabel;
|
||||
$child->error($requiredLabel);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -362,7 +362,9 @@ class InputfieldForm extends InputfieldWrapper {
|
||||
if($required) {
|
||||
if($child->isEmpty()) {
|
||||
if(self::debug) $this->debugNote("$child->name - determined that value IS required and is not present (error)");
|
||||
$child->error($this->requiredLabel); // requiredLabel from InputfieldWrapper
|
||||
$requiredLabel = $child->getSetting('requiredLabel');
|
||||
if(empty($requiredLabel)) $requiredLabel = $this->requiredLabel; // requiredLabel from InputfieldWrapper
|
||||
$child->error($requiredLabel);
|
||||
} else {
|
||||
if(self::debug) $this->debugNote("$child->name - determined that value IS required and is populated (good)");
|
||||
}
|
||||
|
Reference in New Issue
Block a user