Viewing 2 reply threads
  • Author
    Posts
    • #1361
      pupppet
      Member

      Searched the heck out of this one but no dice- How do I test if a checkbox option has been selected?

      This is the only help I’ve found on using fields but there’s nothing on checkboxes- http://piklist.com/user-guide/tutorials/building-settings-pages/.

    • #1365
      Steve
      Keymaster

      @pupppet– Getting the value for a radio button is the same the fields in that tutorial. Did you try it with your radio button field name?

    • #1367
      pupppet
      Member

      Yup but I’m looking to test if a checkbox value has been checked off, not a radio, so the results will be in an array and I didn’t see an example that pulled values from an array (I could have just missed it, my apologies if so!)-

      piklist('field', array(
        'type' => 'checkbox'
        ,'field' => 'theme_regions'
        ,'label' => __('Active Regions:')
        ,'description' => __('')
        ,'value' => ''
        ,'choices' => array(
          'hero' => 'Hero'
          ,'layout_above' => 'Above Layout'
          ,'content_above' => 'Above Content'
          ,'content_below' => 'Below Content'
          ,'layout_below' => 'Below Layout'
        )
      ));
      

      This wordy thing is what I settled on but I figured there’s a better way…

      if (($theme_options['theme_regions'] == 'hero') OR (is_array($theme_options['theme_regions']) && (in_array("hero", $theme_options['theme_regions'])))) {
      ...
      }
Viewing 2 reply threads
  • You must be logged in to reply to this topic.