# If all options are valid, array_intersect of the valid options
# and the provided options will return the provided options.
- $validOptions = HTMLFormField::flattenOptions( $this->mParams['options'] );
+ $validOptions = HTMLFormField::flattenOptions( $this->getOptions() );
$validValues = array_intersect( $value, $validOptions );
if ( count( $validValues ) == count( $value ) ) {
}
function getInputHTML( $value ) {
- $html = $this->formatOptions( $this->mParams['options'], $value );
+ $value = HTMLFormField::forceToStringRecursive( $value );
+ $html = $this->formatOptions( $this->getOptions(), $value );
return $html;
}
function formatOptions( $options, $value ) {
$html = '';
- $attribs = array();
-
- if ( !empty( $this->mParams['disabled'] ) ) {
- $attribs['disabled'] = 'disabled';
- }
+ $attribs = $this->getAttributes( array( 'disabled', 'tabindex' ) );
+ $elementFunc = array( 'Html', $this->mOptionsLabelsNotFromMessage ? 'rawElement' : 'element' );
foreach ( $options as $label => $info ) {
if ( is_array( $info ) ) {
in_array( $info, $value, true ),
$attribs + $thisAttribs
);
- $checkbox .= ' ' . Html::rawElement(
+ $checkbox .= ' ' . call_user_func( $elementFunc,
'label',
array( 'for' => "{$this->mID}-$info" ),
$label
}
/**
- * @param $request WebRequest
+ * @param WebRequest $request
*
- * @return String
+ * @return string
*/
function loadDataFromRequest( $request ) {
if ( $this->mParent->getMethod() == 'post' ) {
}
function filterDataForSubmit( $data ) {
- $options = HTMLFormField::flattenOptions( $this->mParams['options'] );
+ $data = HTMLFormField::forceToStringRecursive( $data );
+ $options = HTMLFormField::flattenOptions( $this->getOptions() );
$res = array();
foreach ( $options as $opt ) {
- $res["$opt"] = in_array( $opt, $data );
+ $res["$opt"] = in_array( $opt, $data, true );
}
return $res;