This is so that we can eventually replace the wrongfully-used CheckMatrix in SpecialBotPasswords with a MultiSelect while keeping all of the existing functionality.
Description
Status | Subtype | Assigned | Task | ||
---|---|---|---|---|---|
Declined | Huji | T150079 Special:BotPasswords Visual indication between checkboxes and corresponding text should be clearer | |||
Open | None | T168724 HTMLMultiSelect should have a parameter for tooltips | |||
Invalid | None | T168728 Tooltips are briefly shown and then disappear for CheckboxMultiselectInputWidget |
Event Timeline
@Volker_E your help is appreciated here.
Below is the snippet of code I am using. As soon as I uncomment the help item in the choices array I get an error message: Catchable fatal error: Method OOUI\HtmlSnippet::__toString() must return a string value in /var/www/html/vendor/oojs/oojs-ui/php/Element.php on line 198
Why is an empty parameter causing that error?
$out = $this->getOutput(); $out->setPageTitle( $this->msg( 'boilerplate-helloworld' ) ); $out->addHelpLink( 'How to become a MediaWiki hacker' ); $out->addWikiMsg( 'boilerplate-helloworld-intro' ); $formDescriptor = [ 'choices' => [ 'type' => 'multiselect', 'options' => [ 'Alphas' => 'alpha', 'Bravos' => 'bravo', 'Charlies' => 'charlie' ], //'help' => [], 'disabled-options' => [ 'bravo' ], 'default' => [ 'bravo', 'charlie' ], ], ]; $htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext(), 'testform' ); $htmlForm->setSubmitText( 'Submit Form' ); $htmlForm->setSubmitCallback( [ 'SpecialHelloWorld', 'trySubmit' ] ); $htmlForm->show();
If I understand this correctly, each new field in an HTMLForm creates as HTMLFormField which uses a FieldLayout. A FieldLayout is the only element that allows a help attribute that shows up as as icon with a popup. The HTMLMultiselect uses a CheckboxMultiselectInputWidget which uses a single FieldLayout to wrap the label and the checkboxes, and so the help attribute can only take a string, not an array.
$formDescriptor = [ 'choices' => [ 'type' => 'multiselect', 'options' => [ 'Alphas' => 'alpha', 'Bravos' => 'bravo', 'Charlies' => 'charlie' ], 'help' => 'Foo bar', 'disabled-options' => [ 'bravo' ], 'default' => [ 'bravo', 'charlie' ], ], ];
This would give you:
Right now the only way to have a tooltip with every checkbox would be to have separate checkboxes:
$options = [ 'Alphas' => 'alpha', 'Bravos' => 'bravo', 'Charlies' => 'charlie' ]; foreach( $options as $label => $data ) { $formDescriptor[ $data ] = [ 'type' => 'check', 'label' => $label, 'data' => $data, 'help' => $label, // Something useful here ]; }
This would give you:
@matmarex How do we want to implement this? Should we add multiple FieldLayouts in CheckboxMultiselectWidget or just add frameless PopupButtonWidgets?