03-31-2014, 12:03 AM
[eluser]Lykos22[/eluser]
Hi, I'd like some help please. I have this form group: This is the view:
Basicly this works as an on/off switch button. The problem is that when I click the submit button of the form, I cannot get the $_POST data of the field ( $this->input->post('visible') ) in order to pass it to my model and store it in the database.
Any ideas what I'm doing wrong and how should fix it?
Hi, I'd like some help please. I have this form group: This is the view:
Code:
<?php echo form_open('admin/posts/post/'.$post->id); ?>
// other fields here...
<div class="form-group">
<label for="visible" class="col-sm-2">Visible</label>
<div class="col-sm-10">
<div class="onoffswitch">
<?php
$is_checked = ($post->visible) ? $post->visible : $this->input->post('visible');
$visible = array(
'class' => 'onoffswitch-checkbox',
'id' => 'visible',
'checked' => ($is_checked == '1') ? true : false,
'name' => 'visible',
'value' => $is_checked,
);
?>
<?php echo form_checkbox($visible); ?>
<label class="onoffswitch-label" for="visible">
<div class="onoffswitch-inner"></div>
<div class="onoffswitch-switch"></div>
</label>
</div>
</div>
</div>
// more fields here ...
<?php echo form_close(); ?>
Any ideas what I'm doing wrong and how should fix it?