php - Can I get a form_multiselect() to return the values I pass in rather than indexes? -


i have form_multiselect() perform search on items associated tags. form:

<div class="control-group">        <?= form_label('tags: ', 'tag', $label_attr);?>         <div class="controls">            <?= form_multiselect('tag[]',$tags,'','id="tag-select"');?>        </div> </div> 

i fill form get_tags() model:

public function get_tags() {     $this->db->select('tag_name');     $this->db->distinct();     $this->db->from('offers_tags');      $query = $this->db->get();      $results = $query->result_array();      $tags_arr= array();     $i = 0;     foreach ($results $id => $tag_name){         foreach ($tag_name $name){             $tags_arr[$i] = $name;             ++$i;         }     }      return $tags_arr;       } 

i loop through associative $results array returned query. if not, form filled indexes , associated arrays, when want list of tag names click.

upon submit, data, passing data larger query results later, following:

$tag_arr = $this->input->get('tag'); 

the problem i'm having form gets index of whatever tag selected form. need actual tag string returned through get. ex: /../../..&tag%5b%5d=8 8 being index of tag selected, rather need tag.

any appreciated, thanks.

**testing update: still no solution correct data. tried passing results_array() query form_multiselect() , obtained after selecting item, pulled value 'tag_name'. assume it's passing name of tuple query pulled because associative array.

also tried looping through results pass new array form results_array() loop:

foreach ($results $id => $tag_name){    $tags_arr[$id] = $tag_name; } 

so still looking string data form. can name of tuple , index of string data.

i not able find information of using array_values() function. tried no avail, still having 'submit' return index values multiselect, finishing get_tags() function with:

$tags_final = array_values($tags_arr); return $tags_final; 

still searching answer, please or bump @ least, it's been weeks.

for individuals encounter same problem:

the following loop performed on resultant query did trick!

    $query = $this->db->get();     $tags = array();      foreach($query->result() $row)     {          $tags[$row->tag_id] = $row->tag_name;     }     return $tags; 

Comments

Popular posts from this blog

php - render data via PDO::FETCH_FUNC vs loop -

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

The canvas has been tainted by cross-origin data in chrome only -