Discuss Help:Datatype "Boolean"

From semantic-mediawiki.org

Contents

Thread titleRepliesLast modified
Use of boolean property value in a form. 123:02, 21 October 2015
format #x doesnt work116:28, 19 March 2015
Boolean formatting question011:29, 4 March 2015
other lenguages #ifeq and boolean217:34, 5 January 2013

Use of boolean property value in a form.

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;

}

20: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

23:02, 21 October 2015
 

format #x doesnt work

After Upgrading my wiki to 1.24.1 the formatoption #x doesnt work. In the table the cell with value false is missing and all following columns ar missplaced, the last column is missing. Also format "#ok," doesnt work. Example:

{{#ask: [[Question::Value]] |?Value1=Column A |?BoolValue#x=Column B |?Value2=Column C }}

gives me

Column A Column B Column C
result 1 X result 1.1
result 2 result 2.1
result 3 X result 3.1

--TomyLee (talk) 10:55, 19 March 2015 (CET)

11:55, 19 March 2015

Boolean formatting question

Sorry, this may be a bit of a basic question but when people edit using a form I'd like the checkbox for a boolean property to output "Yes" when ticked and a blank space when unticked rather than "No". How can I do this? Thanks

11:29, 4 March 2015

other lenguages #ifeq and boolean

If I'm using boolean in other languages, can't I use English or 1/0 or t/f in a conditional with parserfunction #ifeq?

i:e:

{{#ifeq|{{{Choose|}}}|t|bla bla bla|blo blo blo}}</code>

or

{{#ifeq|{{{Choose|}}}|1|bla bla bla|blo blo blo}}</code>

don't works well if my wiki language is Catalan.

15:12, 5 January 2013

Hmm..., try to replace the two system messages with the string you would like to use for this.

16:36, 5 January 2013

But, if I understand, this is to replace throught a query. And what I want is to check it inside a Template with the parserfunction. The conditonal works well if saying (true in Catalan):

{{#ifeq|{{{Choose|}}}|Veritat|bla bla bla|blo blo blo}}

but I prefere to say (true by number):

{{#ifeq|{{{Choose|}}}|1|bla bla bla|blo blo blo}}

to reuse the template in other languages and not depending in changes in the translation

17:34, 5 January 2013