Bartosz Dziewoński has uploaded a new change for review.
https://gerrit.wikimedia.org/r/226070
Change subject: TextInputWidget: Handle required: true better
......................................................................
TextInputWidget: Handle required: true better
* Use indicator: 'required' by default.
Change-Id: Iec208c263064b6e4dba1947f4701010ed9ae15e2
---
M demos/pages/widgets.js
M demos/widgets.php
M php/widgets/TextInputWidget.php
M src/widgets/TextInputWidget.js
4 files changed, 15 insertions(+), 6 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/oojs/ui refs/changes/70/226070/1
diff --git a/demos/pages/widgets.js b/demos/pages/widgets.js
index f6b95ce..db7ea8f 100644
--- a/demos/pages/widgets.js
+++ b/demos/pages/widgets.js
@@ -777,12 +777,11 @@
),
new OO.ui.FieldLayout(
new OO.ui.TextInputWidget( {
- indicator: 'required',
required: true,
validate: 'non-empty'
} ),
{
- label: 'TextInputWidget
(indicator, required)\u200E',
+ label: 'TextInputWidget
(required)\u200E',
align: 'top'
}
),
diff --git a/demos/widgets.php b/demos/widgets.php
index 9acc4bf..88e9a07 100644
--- a/demos/widgets.php
+++ b/demos/widgets.php
@@ -573,11 +573,10 @@
),
new OOUI\FieldLayout(
new
OOUI\TextInputWidget( array(
- 'indicator' =>
'required',
'required' =>
true
) ),
array(
- 'label' =>
"TextInputWidget (indicator, required)\xE2\x80\x8E",
+ 'label' =>
"TextInputWidget (required)\xE2\x80\x8E",
'align' => 'top'
)
),
diff --git a/php/widgets/TextInputWidget.php b/php/widgets/TextInputWidget.php
index 482ca5f..636035f 100644
--- a/php/widgets/TextInputWidget.php
+++ b/php/widgets/TextInputWidget.php
@@ -45,7 +45,8 @@
* @param number $config['maxLength'] Maximum allowed number of
characters to input
* @param boolean $config['multiline'] Allow multiple lines of text
(default: false)
* @param int $config['rows'] If multiline, number of visible lines in
textarea
- * @param boolean $config['required'] Mark the field as required
(default: false)
+ * @param boolean $config['required'] Mark the field as required.
+ * Implies `indicator: 'required'`. (default: false)
* @param boolean $config['autocomplete'] If the field should support
autocomplete
* or not (default: true)
*/
@@ -63,6 +64,11 @@
$config['icon'] = 'search';
}
}
+ if ( $config['required'] ) {
+ if ( !array_key_exists( 'indicator', $config ) ) {
+ $config['indicator'] = 'required';
+ }
+ }
// Parent constructor
parent::__construct( $config );
diff --git a/src/widgets/TextInputWidget.js b/src/widgets/TextInputWidget.js
index 036c80e..45a015c 100644
--- a/src/widgets/TextInputWidget.js
+++ b/src/widgets/TextInputWidget.js
@@ -47,7 +47,7 @@
* Defaults to the maximum of `10` and `2 * rows`, or `10` if `rows` isn't
provided.
* @cfg {string} [labelPosition='after'] The position of the inline label
relative to that of
* the value or placeholder text: `'before'` or `'after'`
- * @cfg {boolean} [required=false] Mark the field as required
+ * @cfg {boolean} [required=false] Mark the field as required. Implies
`indicator: 'required'`.
* @cfg {boolean} [autocomplete=true] Should the browser support autocomplete
for this field
* @cfg {RegExp|Function|string} [validate] Validation pattern: when string, a
symbolic name of a
* pattern defined by the class: 'non-empty' (the value cannot be an empty
string) or 'integer'
@@ -67,6 +67,11 @@
}
// indicator: 'clear' is set dynamically later, depending on
value
}
+ if ( config.required ) {
+ if ( config.indicator === undefined ) {
+ config.indicator = 'required';
+ }
+ }
// Parent constructor
OO.ui.TextInputWidget.parent.call( this, config );
--
To view, visit https://gerrit.wikimedia.org/r/226070
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iec208c263064b6e4dba1947f4701010ed9ae15e2
Gerrit-PatchSet: 1
Gerrit-Project: oojs/ui
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits