Page MenuHomePhabricator

HTMLInfoField with a default value of "0" in an OOUI HTMLForm shows an empty string instead
Closed, ResolvedPublic




class SpecialTest extends FormSpecialPage {
	public function __construct() {
		parent::__construct( 'Test', '', false );

	protected function getFormFields() : array {
		return [
			'info' => [
				'type' => 'info',
				'label' => 'info',
				'raw' => true,
				'default' => "0"

	public function onSubmit( array $data ) {
		wfVarDump( $data );

		return true;

	protected function getDisplayFormat() {
		$useooui = $this->getRequest()->getBool( 'useooui', true );
		return $useooui ? 'ooui' : 'table';

When using the form in OOUI mode, the info field will display nothing. In table mode (provide useooui=0) it will display 0.

Event Timeline

As a quick workaround, setting raw => true and then defining default as '&zwnj;0' does show the expected value, as PHP can't coerce the 0 to an empty string anymore.

Change 467454 had a related patch set uploaded (by Bartosz Dziewoński; owner: Bartosz Dziewoński):
[oojs/ui@master] Allow setting the label to "0" in PHP

Change 467454 merged by jenkins-bot:
[oojs/ui@master] Allow setting the label to "0" in PHP

Volker_E triaged this task as High priority.
Volker_E moved this task from Backlog to OOUI-0.29.3 on the OOUI board.
Volker_E edited projects, added OOUI (OOUI-0.29.3); removed OOUI.
Volker_E removed a project: Patch-For-Review.
Volker_E removed a subscriber: gerritbot.

Change 470967 had a related patch set uploaded (by VolkerE; owner: VolkerE):
[mediawiki/core@master] Update OOUI to v0.29.3

Change 470967 merged by jenkins-bot:
[mediawiki/core@master] Update OOUI to v0.29.3