I inherited code from an old server. This is the code:
<ul>
<?php
$field = get_field_object('field_591de98804dfb');
$choices = $field['choices'];
?>
<?php foreach ($choices as $sector) : ?>
<li>
<label>
<input type="checkbox" name="sector[]" value="<?php print $sector; ?>" <?php /* if ( $sector, array($_GET['sector']) ) : ?> checked <?php endif; */ ?> <?php if (in_array($sector, $_POST['sector'])) echo "checked='checked'"; ?> >
<span class="checkbox"></span> <span class="label"><?php print $sector; ?></span>
</label>
</li>
<?php endforeach; ?>
</ul>
The code works on the old server to filter and the checkboxes remain checked even after the form is submitted. I am on Php 5.6 and I get the following error/s: Warning : in_array() expects parameter 2 to be array, null given in…
I tried changing the filter to: <?php if (in_array($sector, $_POST['sector'])) echo "checked='checked'"; ?> and it’s not woking, idea pointers or ides?