[resolved] Checkbox HTML Output (4 posts)

  1. Jay Hoffmann
    Posted 2 years ago #

    I am trying to output different html based on if a checkbox is selected or not. Basically, this is so a different class is assigned to the div tag. Right now I have:

    <?php echo(types_render_field("inset", array("checked_html"=>base64_encode('<div class="infoBlock">'),"unchecked_html"=>base64_encode('<div class="infoBlockgreen">')))); ?>

    but this is outputting nothing at all. What am I doing wrong?


  2. Jay Hoffmann
    Posted 2 years ago #

    Wasn't able to figure out how use the Types API to do this so I just set up a conditional statement for the custom field value:

    <?php $inset=get_post_meta($post->ID, 'wpcf-inset', true); ?>
    <?php if($inset == "1") { ?>
        <div class="infoBlockgreen">
    <?php } else { ?>
    <div class="infoBlock">
    <?php } ?>

    Pretty simple, the custom field key will be the "wpcf-" prefix plus whatever the slug of the Types field you set up is.

  3. AmirHelzer
    Plugin Author

    Posted 2 years ago #

    To debug this, I would enable debug mode (see PHP issues) and also try to use 'raw'=>'true', just to see if the field name is correct (which it should).

    Anyway, I'll mark this as resolved, as you have a different solution. If you want to continue debugging the intended use, let me know.

  4. bryomedia
    Posted 2 years ago #

    Please put the recommended solution for others to see. Thank you.

    Great plugin, but documentation isn't for the beginner type.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Types
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic