Help!! radiobox, checkbox, dropdownlist

Discuss anything that's related to the Raxan framework

Help!! radiobox, checkbox, dropdownlist

Postby fc_Rohan » Thu Mar 17, 2011 6:50 pm

How do i set the selected and checked option from values return from a database to a radiobox, checkbox and dropdownlist.
fc_Rohan
 
Posts: 3
Joined: Thu Mar 17, 2011 6:46 pm

Re: Help!! radiobox, checkbox, dropdownlist

Postby fc_Damir » Thu Mar 17, 2011 8:46 pm

Hi Rohan,

you can do in this way:

php:
Code: Select all
    protected function _myviewView(){
      $id = $this->get->intVal(0);

      $this->field_id->bind($this->db->table('mytable field_id, field_title'));  //this must be first (load data of database table mytable into select list)

      $data = $this->db->table('comments','comment_id=?',$id);  //this must be second

       if($data) $this->myform->inputValues($data[0]);   // this is last (bind database result into form)

      }


html:
Code: Select all

    <form action="" method="post" name="myform" id="myform">

      <div class="ctrl-group">
        <label class="left c5" for="field_id">Category: </label>
        <select name="field_id" id="field_id" class="textbox">
          <option value="{field_id}">{field_title}</option>
        </select>
      </div>

      <div class="ctrl-group">
        <label class="left c5" for="post_date">Date: </label>
        <input class="textbox c10" type="text" name="post_date" id="post_date">
      </div>

      <div class="ctrl-group prepend5">
        <input class="button process" type="submit" name="save" value="Save">
      </div>

    </form>


Important: The name and id attribute of form's element must be the same of database field name.

In this way raxan add automaticly 'selected' to correct item of list.

I hope this can help you.

Best regards
Damir
fc_Damir
 
Posts: 33
Joined: Mon Jun 14, 2010 9:13 am

Re: Help!! radiobox, checkbox, dropdownlist

Postby fc_Rohan » Thu Mar 17, 2011 9:04 pm

:D PERFECT THANKS BRO
fc_Rohan
 
Posts: 3
Joined: Thu Mar 17, 2011 6:46 pm


Return to General Discussions

Who is online

Users browsing this forum: No registered users and 1 guest

cron