* (wpFormIdentifier).
*
* @param WebRequest $request
- * @return boolean
+ * @return bool
*/
protected function isSubmitAttempt( WebRequest $request ) {
return $request->getCheck( 'wpEditToken' ) || $request->getCheck( 'wpFormIdentifier' );
// the element could specify, that the label doesn't need to be added
$label = $this->getLabel();
- if ( $label ) {
+ if ( $label && $label !== ' ' ) {
$config['label'] = new OOUI\HtmlSnippet( $label );
}
/**
* Get a FieldLayout (or subclass thereof) to wrap this field in when using OOUI output.
+ * @param string $inputField
+ * @param array $config
* @return OOUI\FieldLayout|OOUI\ActionFieldLayout
*/
protected function getFieldLayoutOOUI( $inputField, $config ) {
}
/**
- * Whether the field should be automatically infused. Note that all OOjs UI HTMLForm fields are
+ * Whether the field should be automatically infused. Note that all OOUI HTMLForm fields are
* infusable (you can call OO.ui.infuse() on them), but not all are infused by default, since
* there is no benefit in doing it e.g. for buttons and it's a small performance hit on page load.
*
/**
* Get the list of extra ResourceLoader modules which must be loaded client-side before it's
- * possible to infuse this field's OOjs UI widget.
+ * possible to infuse this field's OOUI widget.
*
* @return string[]
*/
$this->mOptionsLabelsNotFromMessage = true;
$this->mOptions = self::forceToStringRecursive( $this->mParams['options'] );
} elseif ( array_key_exists( 'options-message', $this->mParams ) ) {
- /** @todo This is copied from Xml::listDropDown(), deprecate/avoid duplication? */
$message = $this->getMessage( $this->mParams['options-message'] )->inContentLanguage()->plain();
-
- $optgroup = false;
- $this->mOptions = [];
- foreach ( explode( "\n", $message ) as $option ) {
- $value = trim( $option );
- if ( $value == '' ) {
- continue;
- } elseif ( substr( $value, 0, 1 ) == '*' && substr( $value, 1, 1 ) != '*' ) {
- # A new group is starting...
- $value = trim( substr( $value, 1 ) );
- $optgroup = $value;
- } elseif ( substr( $value, 0, 2 ) == '**' ) {
- # groupmember
- $opt = trim( substr( $value, 2 ) );
- if ( $optgroup === false ) {
- $this->mOptions[$opt] = $opt;
- } else {
- $this->mOptions[$optgroup][$opt] = $opt;
- }
- } else {
- # groupless reason list
- $optgroup = false;
- $this->mOptions[$option] = $option;
- }
- }
+ $this->mOptions = Xml::listDropDownOptions( $message );
} else {
$this->mOptions = null;
}
return null;
}
- $options = [];
-
- foreach ( $oldoptions as $text => $data ) {
- $options[] = [
- 'data' => (string)$data,
- 'label' => (string)$text,
- ];
- }
-
- return $options;
+ return Xml::listDropDownOptionsOoui( $oldoptions );
}
/**
* Whether this field requires the user agent to have JavaScript enabled for the client-side HTML5
* form validation to work correctly.
*
- * @return boolean
+ * @return bool
* @since 1.29
*/
public function needsJSForHtml5FormValidation() {