Topic on Talk:HTMLForm

htmlform-select-badoption errors

1
Rstockbower (talkcontribs)

If you're building a select dropdown and you're getting htmlform-select-badoption errors, try adding a default value. This array was throwing errors:

Array
(
    [Amsterdam] => AMS
    [Barcelona] => BCN
    [Berlin] => BER
    [Bhiwandi] => BHI
    [Deer Park] => DPK
    [The Hague] => HAG
    [Hong Kong] => HKG
    [Lexington] => LEX
    [Montego Bay] => MBY
    [Mumbai] => MUM
    [Paris] => PAR
    [Silver Spring] => SSM
    [Singapore] => SGP
    [Sydney] => SYD
    [Tunis] => TUN
    [Vadodara] => VAD
    [Venlo] => VEN
    [Windsor] => WND
    [Winterthur] => WTR
)

Copying the array from the tutorial did not throw errors:

Array
(
    [Option 0] => 0
    [Option 1] => 1
    [Option 2] => option2id
)

Note that their structures are the same; one is just a bit more complex than the other.

Making an explicit default got rid of the error message:

'office' => array(
	'name' => 'office',
	'type' => 'select',
	'label' => wfMessage('in-office')->parse(),
	'section' => 'convert-from-section-label',
	'options' => $this->buildOfficeList(),
	'default' => self::BLANK,
),
Reply to "htmlform-select-badoption errors"