public function __construct( $params ) {
parent::__construct( $params );
+ // If the disabled-options parameter is not provided, use an empty array
+ if ( isset( $this->mParams['disabled-options'] ) === false ) {
+ $this->mParams['disabled-options'] = [];
+ }
+
// For backwards compatibility, also handle the old way with 'cssclass' => 'mw-chosen'
if ( isset( $params['dropdown'] ) || strpos( $this->mClass, 'mw-chosen' ) !== false ) {
$this->mClass .= ' mw-htmlform-dropdown';
'id' => "{$this->mID}-$info",
'value' => $info,
];
+ if ( in_array( $info, $this->mParams['disabled-options'], true ) ) {
+ $thisAttribs['disabled'] = 'disabled';
+ }
$checked = in_array( $info, $value, true );
$checkbox = $this->getOneCheckbox( $checked, $attribs + $thisAttribs, $label );
}
}
+ /**
+ * Get options and make them into arrays suitable for OOUI.
+ * @return array Options for inclusion in a select or whatever.
+ */
+ public function getOptionsOOUI() {
+ $options = parent::getOptionsOOUI();
+ foreach ( $options as &$option ) {
+ $option['disabled'] = in_array( $option['data'], $this->mParams['disabled-options'], true );
+ }
+ return $options;
+ }
+
/**
* Get the OOUI version of this field.
*