Tagged: 

Viewing 9 reply threads
  • Author
    Posts
    • #2079
      exacks44
      Member

      Hello,

      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 🙂

    • #2080
      Kevin
      Keymaster

      @exacks44

      Can you post some more information? If possible please post the radio field code and how you are pulling the data from the system.

      Thanks,

      Kevin

    • #2081
      exacks44
      Member

      Here 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, like array { [0]=> "list" }

      Thank you

    • #2082
      Kevin
      Keymaster

      @exacks44

      How are you loading data into $my_plugin_settings is what I need to know. Are you using get_post_meta or the piklist function or something else?

      Thanks,

      Kevin

    • #2083
      exacks44
      Member

      I do not use any function, do I have to?

      For example, I use:

      if ( $my_plugin_settings['display_type'] == 'grid' ) {
         ...do some stuff...
      }
    • #2084
      Steve
      Keymaster

      @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?

    • #2086
      exacks44
      Member

      Actually, 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" }

    • #2087
      Steve
      Keymaster

      @exacks44– Fixed in v0.9.4.2.

    • #2090
      exacks44
      Member

      Thank you very much for the quick and perfect support!

    • #2091
      Steve
      Keymaster

      @exacks44– You’re very welcome. Closing this ticket.

Viewing 9 reply threads
  • The topic ‘Radio field returns array instead of string’ is closed to new replies.