Jump to content


POST or GET g-crud default values

post get field_type hidden default

  • Please log in to reply
No replies to this topic

#1 Martin Lobato

Martin Lobato

    Member

  • Members
  • PipPip
  • 14 posts

Posted 24 February 2017 - 06:31 PM

hi, Im not a newbie but no expert.

 

GOAL: Send default values via post or get to an EDIT and/or ADD, catch them and set a field_type hidden with a default.

 

1) I have try to make a post viaja ajax to a function with a g-crud, but unfortunatlly it messes with the ajax_list and some other ajax functionalities, If a make $this->input->is_ajax_request(); It broke's.

 

2) If I try to make a get myweb.com?term=1234 when I click add or edit it appears that field_type is lost. How I know this, when I click edit, the field is there waiting for me to complete it.

if($this->input->get()!=null){
                $get=$this->input->get(null,true);
                print_r($get);
                foreach ($get as $key => $value) {                    
                   $crud->field_type($key, 'hidden', $value); //if is not define in DB nothing explodes.
                }
            }

3) Making a post requere a library for restfull api for codeigniter in order to make a post from a controller. for now i have investigated, there are some...  but haven tryed yet. 

 

 

So if any one who has much more expirience with php codeigniter and g-crud could give me a hand with this could be great!

 

Thanks!

 

 

 

 

 

edit1: as 'always' I find a way to make it.... dont know if the best way or the only one. 

 

at the end of the url i.e: add?bill_supp_id=6 or edit?bill_supp_id=6

 

and you can make a big ifelse (or maybe a switchcase)

if (isset($supp_id)and is_numeric($supp_id)) {
                $crud->order_by('bill_date','DESC');
                $crud->where('bill_supp_id',$supp_id);
                $extra['company_name']= $this->db->get_where('company', array('id'=>$supp_id))->row()->company_name;
                $extra['supp_id']= $supp_id;
                //$crud->set_relation('bill_supp_id','company','company_name', array('id'=>$supp_id) );
                $crud->field_type('bill_supp_id', 'hidden', $supp_id);
            }
            elseif($this->input->get()!=null){
                $get=$this->input->get(null,true);
                print_r($get);                
                foreach ($get as $key => $value) {                    
                   $crud->field_type($key, 'hidden', $value);
                   echo $key.'-'.$value;
                }
            }
            else{
                $crud->order_by('bill_state','asc');
                $crud->set_relation('bill_supp_id','company','company_name');
                $crud->columns(
                'bill_supp_id',
                'bill_number',
                'bill_type',
                'bill_date',
                'bill_due_date',
                'bill_amount_subtotal',
                'bill_amount_nogravado',
                'bill_tax_10',
                'bill_tax_21',
                'bill_tax_27',
                'bill_amount_total',
                'bill_state',
                'bill_file'/*,
                'bill_note'*/
                );
            }






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users