Comments Form - email newsletter opt-in
Hello,
In blog/libraries/Fuel_log.php I have added the below for rendering to the page.
$fields['subscribed'] = array('label' => 'Would you like to receive our newsletters?', 'type' => 'checkbox', 'class' => 'form-control', 'checked' => true, 'value' => 1);
And in models/Blog_comments_model.php added 'subscribed' to the array of hidden fields so that cms administrators cannot manually over-ride the opt in and out.
The checkbox always saves to the database as 1 (the checked state).
How do I write to the database as 0 or 1 depending on whether the checkbox is checked or unchecked?
Comments
public $boolean_fields = array('subscribed');
Previously I had Default set to 1, I now have set this to 0 - and have observed that it always writes 0 - never 1.
$comment->subscribed = $this->input->post('subscribed', TRUE);
if ( empty( $comment->subscribed) ) { $comment->subscribed = 0; }