Use of boolean property value in a form.

From semantic-mediawiki.org

I created a form with a boolean property value. Then, when i try to use the form to create a page, it shows me thsi error: PHP Warning: in_array() expects parameter 2 to be array, string given in *root*\extensions\SemanticForms\includes\forminputs\SF_CheckboxInput.php on line 67

This is the content of my SF_CheckboxInput.php file:

// Can show up here either as an array or a string, depending on

// whether it came from user input or a wiki page

if ( is_array( $cur_value ) ) {

$isChecked = array_key_exists( 'value', $cur_value ) && $cur_value['value'] == 'on';

} else {

// Default to false - no need to check if it matches

// a 'false' word.

// We use mb_strtolower() here, and not the more

// common strtolower(), because only mb_strtolower()

// works for non-Latin alphabets as well.

$lowercaseCurValue = mb_strtolower( trim( $cur_value ) );


$possibleYesMessages = array(

mb_strtolower( wfMessage( 'htmlform-yes' )->inContentLanguage()->text() ),

// Add in '1', and some hardcoded English.

'1', 'yes', 'true'

);


// Add values from Semantic MediaWiki, if it's installed.

if ( wfMessage( 'smw_true_words' )->exists() ) {

$smwTrueWords = explode( ',', wfMessage( 'smw_true_words' )->inContentLanguage()->text(), true );

foreach ( $smwTrueWords as $smwTrueWord ) {

$possibleYesMessages = mb_strtolower( trim( $smwTrueWord ) );

}

}

$isChecked = in_array( $lowercaseCurValue, $possibleYesMessages );

}

$text = "\t" . Html::hidden( $input_name . '[is_checkbox]', 'true' ) . "\n";

$checkboxAttrs = array(

'id' => $input_id,

'class' => $className,

'tabindex' => $sfgTabIndex

);

if ( $is_disabled ) {

$checkboxAttrs['disabled'] = true;

}

$text .= "\t" . Html::check( "{$input_name}[value]",

$isChecked, $checkboxAttrs );

return $text;

}

19:01, 21 October 2015

Hmm, these booleans. I am not sure but this rather looks like an issue with the Semantic Forms extension. I'd give it a shot at the respective talk page. Do not forget to indicate the versions of MW, SMW and SF as well as PHP you are using. There is no need to quote the code as long as you point to line 67. Cheers

22:02, 21 October 2015