zen_draw_checkbox_field - how do I get my custom field to show selection in checkbox?
Hi guys
I recently added some new fields to my admin product info page. I have four fields - two of them are checkboxes. All are working fine. I can view them frontend too, and have customised it exactly how I need it, thanks to this awesome forum and its generous users, documenting their work. :yes:
I can get the checkbox values to apply to the database, but when revisiting the product, the checkbox state is not observed. eg the box is no longer checked (value 0) even though the db states value 1. Not good.
I suppose I need to store the checkbox state as a new variable and use it, but how? Here's my code for one checkbox, which is a yes/no 1/0 answer.
PHP Code:
<tr>
<td class="main"><?php echo 'Organic '; ?></td>
<td class="main"><?php echo zen_draw_checkbox_field('products_organic', '1', (($pinfo->fields['products_organic'] == '1') ? true : false), 'id="products_organic"') . "Organic"; ?><br /></td>
</tr>
Trial and error got me this far - I'm soooo close to completion its paining me! Anyone?
Thanks guys.
Re: zen_draw_checkbox_field - how do I get my custom field to show selection in check
Bump - can nobody show me how to retrieve the checkbox status from the DB and mark accordingly?
Re: zen_draw_checkbox_field - how do I get my custom field to show selection in check
Quote:
Originally Posted by
johnlewisdesign
Bump - can nobody show me how to retrieve the checkbox status from the DB and mark accordingly?
what happens if you change to this: (not an expert by any means, but my custom fields and all other fields on page use $pinfo->xxxxx instead of $pinfo->fields['xxxxx']
PHP Code:
<tr>
<td class="main"><?php echo 'Organic '; ?></td>
<td class="main"><?php echo zen_draw_checkbox_field('products_organic', '1', (($pinfo->products_organic == '1') ? true : false), 'id="products_organic"') . "Organic"; ?><br /></td>
</tr>