我有3个支票簿,每个支票簿有3个选项。我使用序列化来保存每个支票簿,但如果支票簿有1个答案,我就无法保存数据。
<?php if( ! empty($questiontype)): ?>
<label>Answer Type</label><br>
<label>A</label>
<div class="form-group">
<?php foreach($questiontype as $key => $val): ?>
<label class="checkbox-inline" >
<input name="meta_answertype[][]" value="<?php echo $key; ?>" type="checkbox"<?php if($key == @$meta['answertype'][0][0]) echo 'checked'; ?> /> <?php echo $val; ?>
</label>
<?php endforeach; ?>
</div>
<label>B</label>
<div class="form-group">
<?php foreach($questiontype as $key => $val): ?>
<label class="checkbox-inline">
<input name="meta_answertype[][]" value="<?php echo $key; ?>" type="checkbox"<?php if($key == @$meta['answertype'][1][1]) echo 'checked'; ?> /> <?php echo $val; ?>
</label>
<?php endforeach; ?>
</div>
<label>C</label>
<div class="form-group">
<?php foreach($questiontype as $key => $val): ?>
<label class="checkbox-inline">
<input name="meta_answertype[][]" value="<?php echo $key; ?>" type="checkbox"<?php if($key == @$meta['answertype'][2][2]) echo 'checked'; ?> /> <?php echo $val; ?>
</label>
<?php endforeach; ?>
</div>
<?php endif; ?>