Welcome Guest, Not a member yet? Register   Sign In
Options with boolean value 0
#11

[eluser]CroNiX[/eluser]
I'm sorry, I'm not really sure what you mean by what you just said: "only if the model returning 1 else nothing in value not even the attribute value=”“"

One thing I would do is remove the php for echoing the value. Put that in the regular html portion of the tag. The way you have it written you are not including a space before it echos 'value="1"' so if the item was checked the html would come out like:
Code:
//notice lack of space between checked and value attributes
<input type="checkbox" id="inlineCheckbox1" name="add" checked="checked"value="1" > Add
But that part has no logic (it will always be value="1") so just put it as pure html within the tag
Try writing them like
Code:
<input type="checkbox" id="inlineCheckbox1" name="add" <?php echo ($right->add==1)?'checked="checked"':''; ?> value="1" /> Add

also notice I closed your input with a
Code:
/>
instead of just a >
#12

[eluser]cPage[/eluser]
sorry i edit my post because i realized about the value="1" do not have to be echo, its always value="1" whatever its checked,and if it is not checked then it return FALSE.

The slash / is not required in html 5.

Finish function update
Code:
public function update()
{
  $this->validation();
  
  if ($this->form_validation->run() == FALSE)
  {
   $this->form_error = TRUE;
   $this->edit($this->input->post('id_right'));
  }
  else
  {
   $post = $this->input->post();
   $post['add'] = (int)$this->input->post('add');
   $post['edit'] = (int)$this->input->post('edit');
   $post['delete'] = (int)$this->input->post('delete');
   $this->right_model->update($post,array('id_right' => $post['id_right']));
   $this->common->set_message('alert alert-success',sprintf($this->lang->line('rights_edit_message'),$post['id_right']));
   $this->index();
  }
}

HTML

Code:
<div class="control-group">
  <div class="controls">
   <label class="checkbox inline">
   &lt;input type="checkbox" id="inlineCheckbox1" name="add"
   &lt;?=($right-&gt;add==1)?'checked="checked"':'';?&gt; value="1"> Add
   </label>
   <label class="checkbox inline">
   &lt;input type="checkbox" id="inlineCheckbox2" name="edit"
   &lt;?=($right-&gt;edit==1)?'checked="checked"':'';?&gt; value="1"> Edit
   </label>
   <label class="checkbox inline">
   &lt;input type="checkbox" id="inlineCheckbox3" name="delete"
   &lt;?=($right-&gt;delete==1)?'checked="checked"':'';?&gt; value="1"> Delete
   </label>
  </div>
</div>

Again thank you CroNiX




Theme © iAndrew 2016 - Forum software by © MyBB