Tagged: radio field
- This topic has 9 replies, 3 voices, and was last updated 7 years, 6 months ago by
Steve.
-
AuthorPosts
-
-
July 29, 2014 at 5:59 am #2079
exacks44MemberHello,
I have updated to the newest 0.9.4.1 version of Piklist, and I have now a problem with my radio fields of the setting pages.
On the previous versions, the radio field was returning a string, like ‘option1’, ‘option2’, etc.
string(7) "option1"Now, it’s returning an array with the string as the first argument! Example:
array(1) { [0]=> string(7) "option1" }Could you fix this issue?
Thank you for your great job 🙂
-
July 29, 2014 at 6:16 am #2080
-
July 29, 2014 at 6:26 am #2081
exacks44MemberHere my radio field code:
<?php /* Title: My Plugin Setting: my_plugin_settings Tab Order: 10 */ piklist('field', array( 'type' => 'radio' ,'field' => 'display_type' ,'label' => 'List display' ,'value' => 'grid' ,'choices' => array( 'grid' => 'Grid' ,'list' => 'List' ,'quicksand' => 'jQuery Quicksand' ) ));And I use somewhere else in my plugin this variable to call the value:
$my_plugin_settings['display_type']This variable was returning a string before the update, like
'grid','list'or'quicksand'.
Now I get an array, likearray { [0]=> "list" }Thank you
-
July 29, 2014 at 6:39 am #2082
-
July 29, 2014 at 6:44 am #2083
exacks44MemberI do not use any function, do I have to?
For example, I use:
if ( $my_plugin_settings['display_type'] == 'grid' ) { ...do some stuff... } -
July 29, 2014 at 8:47 am #2084
SteveKeymaster@exacks44– To pull settings from the database you need to use something like get_option.
$my_plugin_settings = get_option('my_plugin_settings');Then you can do the conditional check against “grid”.
Are you using
get_option? -
July 29, 2014 at 9:31 am #2086
exacks44MemberActually, I use
$my_plugin_settings = get_option('my_plugin_settings');I explain again my problem, because I think there is a misunderstanding:
My plugin was working without any trouble until the last version of Piklist. My problem is not how to load data, my problem is that the new version of Piklist is now returning an array instead of a string for radio fields.
With version 0.9.3.6:
var_dump( $my_plugin_settings['a_radio_field'] )
returns
string(4) "grid"With version 0.9.4 (and version 0.9.4.1):
var_dump( $my_plugin_settings['a_radio_field'] )
returns
array(1) { [0]=> string(4) "grid" } -
July 29, 2014 at 2:09 pm #2087
-
July 30, 2014 at 3:41 am #2090
exacks44MemberThank you very much for the quick and perfect support!
-
July 30, 2014 at 9:06 am #2091
-
-
AuthorPosts
- The topic ‘Radio field returns array instead of string’ is closed to new replies.