jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/325121 )
Change subject: Add HiddenInputWidget to generate hidden input
......................................................................
Add HiddenInputWidget to generate hidden input
The widget gets 'name' and 'value' parameters in the configuration.
Bug: T152321
Change-Id: I382d1420ae007683b64da9a3f30b57e78252db8a
---
M build/modules.yaml
M demos/pages/widgets.js
M demos/pages/widgets.php
A php/widgets/HiddenInputWidget.php
A src/widgets/HiddenInputWidget.js
5 files changed, 106 insertions(+), 0 deletions(-)
Approvals:
jenkins-bot: Verified
VolkerE: Looks good to me, approved
Jforrester: Looks good to me, but someone else must approve
diff --git a/build/modules.yaml b/build/modules.yaml
index baeb1ef..cade8e6 100644
--- a/build/modules.yaml
+++ b/build/modules.yaml
@@ -70,6 +70,7 @@
# The basic widgets and layouts, continued.
"src/widgets/InputWidget.js",
+ "src/widgets/HiddenInputWidget.js",
"src/widgets/ButtonInputWidget.js",
"src/widgets/CheckboxInputWidget.js",
"src/widgets/DropdownInputWidget.js",
diff --git a/demos/pages/widgets.js b/demos/pages/widgets.js
index c185350..7a7015e 100644
--- a/demos/pages/widgets.js
+++ b/demos/pages/widgets.js
@@ -2575,6 +2575,18 @@
label:
'Remember me',
align: 'inline'
}
+ ),
+ new OO.ui.FieldLayout(
+ new
OO.ui.HiddenInputWidget( {
+ name: 'hidden',
+ value: 'hidden
value'
+ } )
+ ),
+ new OO.ui.FieldLayout(
+ new
OO.ui.ButtonInputWidget( {
+ type: 'submit',
+ label: 'Submit
form'
+ } )
)
]
} ),
diff --git a/demos/pages/widgets.php b/demos/pages/widgets.php
index 44b6b48..9ee225c 100644
--- a/demos/pages/widgets.php
+++ b/demos/pages/widgets.php
@@ -1101,6 +1101,18 @@
'align' => 'inline',
]
),
+ new OOUI\FieldLayout(
+ new OOUI\HiddenInputWidget( [
+ 'name' => 'hidden',
+ 'value' => 'hidden value',
+ ] )
+ ),
+ new OOUI\FieldLayout(
+ new OOUI\ButtonInputWidget( [
+ 'type' => 'submit',
+ 'label' => 'Submit form',
+ ] )
+ ),
]
] ),
new OOUI\FieldsetLayout( [
diff --git a/php/widgets/HiddenInputWidget.php
b/php/widgets/HiddenInputWidget.php
new file mode 100644
index 0000000..af1b234
--- /dev/null
+++ b/php/widgets/HiddenInputWidget.php
@@ -0,0 +1,43 @@
+<?php
+
+namespace OOUI;
+
+/**
+ * Data widget intended for creating 'hidden'-type inputs.
+ */
+class HiddenInputWidget extends Widget {
+
+ /**
+ * @var string
+ */
+ public static $tagName = 'input';
+
+ /**
+ * DataWidget constructor.
+ *
+ * @param array $config
+ * @param string $config['value'] The data the input contains.
(default: '')
+ * @param string $config['name'] The name of the hidden input.
(default: '')
+ */
+ public function __construct( array $config ) {
+ // Configuration initialization
+ $config = array_merge( [ 'value' => '', 'name' => '' ], $config
);
+
+ // Parent constructor
+ parent::__construct( $config );
+
+ // Initialization
+ $this->setAttributes( [
+ 'type' => 'hidden',
+ 'value' => $config['value'],
+ 'name' => $config['name'],
+ ] );
+ $this->removeAttributes( [ 'aria-disabled' ] );
+ }
+
+ public function getConfig( &$config ) {
+ $config['value'] = $this->getAttribute( 'value' );
+ $config['name'] = $this->getAttribute( 'name' );
+ return parent::getConfig( $config );
+ }
+}
diff --git a/src/widgets/HiddenInputWidget.js b/src/widgets/HiddenInputWidget.js
new file mode 100644
index 0000000..34292ea
--- /dev/null
+++ b/src/widgets/HiddenInputWidget.js
@@ -0,0 +1,38 @@
+/**
+ * Data widget intended for creating 'hidden'-type inputs.
+ *
+ * @class
+ * @extends OO.ui.Widget
+ *
+ * @constructor
+ * @param {Object} [config] Configuration options
+ * @cfg {string} [value=''] The value of the input.
+ * @cfg {string} [name=''] The value of the input’s HTML `name` attribute.
+ */
+OO.ui.HiddenInputWidget = function OoUiHiddenInputWidget( config ) {
+ // Configuration initialization
+ config = $.extend( { value: '', name: '' }, config );
+
+ // Parent constructor
+ OO.ui.HiddenInputWidget.parent.call( this, config );
+
+ // Initialization
+ this.$element.attr( {
+ type: 'hidden',
+ value: config.value,
+ name: config.name
+ } );
+ this.$element.removeAttr( 'aria-disabled' );
+};
+
+/* Setup */
+
+OO.inheritClass( OO.ui.HiddenInputWidget, OO.ui.Widget );
+
+/* Static Properties */
+
+/**
+ * @static
+ * @inheritdoc
+ */
+OO.ui.HiddenInputWidget.static.tagName = 'input';
--
To view, visit https://gerrit.wikimedia.org/r/325121
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I382d1420ae007683b64da9a3f30b57e78252db8a
Gerrit-PatchSet: 7
Gerrit-Project: oojs/ui
Gerrit-Branch: master
Gerrit-Owner: Victorbarbu <[email protected]>
Gerrit-Reviewer: Bartosz Dziewoński <[email protected]>
Gerrit-Reviewer: Florianschmidtwelzow <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: Prtksxna <[email protected]>
Gerrit-Reviewer: Victorbarbu <[email protected]>
Gerrit-Reviewer: VolkerE <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits