⚠ In case you've missed it we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This forum is read-only and soon will be archived. ⚠

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


  • 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.

                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!








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)) {
                $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);
                foreach ($get as $key => $value) {                    
                   $crud->field_type($key, 'hidden', $value);
                   echo $key.'-'.$value;

Also tagged with one or more of these keywords: post, get, field_type, hidden, default

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users