15 parent::__construct( $params );
17 if ( isset( $params[
'flatlist'] ) ) {
18 $this->mClass .=
' mw-htmlform-flatlist';
23 $p = parent::validate( $value, $alldata );
29 if ( !is_string( $value ) && !is_int( $value ) ) {
30 return $this->
msg(
'htmlform-required' );
35 if ( in_array( strval( $value ), $validOptions,
true ) ) {
38 return $this->
msg(
'htmlform-select-badoption' );
58 foreach ( $this->
getOptions() as $label => $data ) {
61 'label' => $this->mOptionsLabelsNotFromMessage ?
new OOUI\HtmlSnippet( $label ) : $label,
65 return new OOUI\RadioSelectInputWidget( [
66 'name' => $this->mName,
69 'options' => $options,
70 ] + OOUI\Element::configFromHtmlAttributes(
80 $attribs = $this->
getAttributes( [
'disabled',
'tabindex' ] );
81 $elementFunc = [ Html::class, $this->mOptionsLabelsNotFromMessage ?
'rawElement' :
'element' ];
83 # @todo Should this produce an unordered list perhaps?
84 foreach ( $options as $label => $info ) {
85 if ( is_array( $info ) ) {
86 $html .= Html::rawElement(
'h1', [], $label ) .
"\n";
89 $id = Sanitizer::escapeIdForAttribute( $this->mID .
"-$info" );
90 $classes = [
'mw-htmlform-flatlist-item' ];
92 $classes[] =
'mw-ui-radio';
94 $radio =
Xml::radio( $this->mName, $info, $info === $value, $attribs + [
'id' => $id ] );
95 $radio .=
"\u{00A0}" . call_user_func( $elementFunc,
'label', [
'for' => $id ], $label );
97 $html .=
' ' . Html::rawElement(
99 [
'class' => $classes ],