Home Forums General Issues Checkbox value conditional statement error


Checkbox value conditional statement error

  • Having issues finding a way to display an ‘X’ in a table cell based on the whether or not one of the checkbox values is checked. Found the below solution on this forum, but it’s throwing the following error:

    Warning: in_array() expects parameter 2 to be array, null given in /home/storm3/public_html/traffic/wp-content/themes/evoResponsive/single-projects.php on line 115

    What am I missing here?

    $crash = get_field('proj_crash');
    echo '<table>';
    echo '<tr>';
    echo '<td>';
    if(in_array('Timeliness', $crash )) { //this is line 115
       echo 'X';
    echo '</td>';
    echo '<td>';
    if(in_array('Accuracy', $crash )) { //same error generated here
       echo 'X';
    echo '</td>';
    echo '</tr>';
    echo '</table>';
  • BTW, I checked this thread, and a var dump returns ‘NULL’.

    I don’t understand why a field with boxes checked would return NULL, nor why the solution that worked in the thread above does not work for me.

  • DOH! This is a repeater field, and this works:

    while(have_rows(‘project_areas’)): the_row();

    <td class=”align-center”>
    if( get_sub_field(‘proj_crash’) ) {
    if( in_array( ‘Timeliness’, get_sub_field(‘proj_crash’) ) )
    echo ‘X’;
    <?php endwhile;

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Checkbox value conditional statement error’ is closed to new replies.