+ // It is impossible to submit a form with hidden fields failing validation, e.g. one that
+ // is required. However, validity is not checked for disabled fields, as these are not
+ // submitted with the form. So we should also disable fields when hiding them.
+ this.textinput.setDisabled( textinputIsHidden || disabled );
+ };
+
+ /**
+ * Set the value from outside.
+ *
+ * @param {string|undefined} value
+ */
+ mw.widgets.SelectWithInputWidget.prototype.setValue = function ( value ) {
+ var selectable = false;
+
+ if ( this.or ) {
+ if ( value !== 'other' ) {
+ selectable = !!this.dropdowninput.dropdownWidget.getMenu().findItemFromData( value );
+ }
+
+ if ( selectable ) {
+ this.dropdowninput.setValue( value );
+ this.textinput.setValue( undefined );
+ } else {
+ this.dropdowninput.setValue( 'other' );
+ this.textinput.setValue( value );
+ }
+
+ this.emit( 'change', value );
+ }
+ };
+
+ /**
+ * Get the value from outside.
+ *
+ * @return {string}
+ */
+ mw.widgets.SelectWithInputWidget.prototype.getValue = function () {
+ if ( this.or ) {
+ if ( this.dropdowninput.getValue() !== 'other' ) {
+ return this.dropdowninput.getValue();
+ }
+
+ return this.textinput.getValue();
+ } else {
+ return '';
+ }