function somefunction(){ $crud = new Grocery_CRUD(); $crud->set_table('some_table'); /*...*/ $crud->callback_field('some_field', array($this,'callback_selectImage'));//normal call $crud->callback_field('some_other_field', array($this,'callback_selectImage')); //normal call
/*...*/ $this->salida($output); }
public function callback_selectImage($value="", $primary_key = null, $callback) { $img = new Images_model(); //object to table images $res = $img->get_all_img_buttons(); //get all images $out = '<select class="form-control select2 sel_image" id="field-'.$callback->name.'" name="'.$callback->name.'" placeholder="Seleccionar Tipo" >'; $out .= '<option value="" selected disabled>Seleccionar</option>'; foreach($res as $key=>$val): if($value == $val->image_id): $out .= '<option value="'.$val->image_id.'" title="'.base_url().'assets/uploads/imgs/'.$val->image_url.'" selected>'.$val->image_name.'</option>'; else: $out .= '<option value="'.$val->image_id.'" title="'.base_url().'assets/uploads/imgs/'.$val->image_url.'">'.$val->image_name.'</option>'; endif; endforeach; $out .= '</select>'; return $out; }