Jump to content


marlaaragao

Member Since 06 Jun 2015
Offline Last Active May 11 2016 01:29 AM
-----

Posts I've Made

In Topic: master-child LAYOUT

04 November 2015 - 12:44 PM

Try setting your add_action like this:

$crud->add_action('Articles', '' , 'FracturesController/list_articles', 'fa fa-list-alt')

and your function like this:

function list_articles($primary_key) {
  
  $crud1= new Grocery_CRUD(); 
  $crud1->set_table('articles');
  $crud1->where(`id_facture`,$primary_key);

  $output=$crud1->render();

  $this->load->view('YourView', $output);
}

In Topic: Bootstrap Theme - Unset Search by Column

21 October 2015 - 10:56 AM

Does anyone know how to do it? Thanks!


In Topic: Issue with Add_action

21 October 2015 - 10:54 AM

Hi! Sorry for the late response.

 

I don't know WHY it happens, or if it's the desired behavior, but I know that it happens when you have the last parameter (url_callback) set in

 

void add_action( string $label, string $image_url , string $link_url , string $css_class , mixed $url_callback)

 

So, what you have to do is to add your action like this:

$crud->add_action('Label', 'YourImageURL' , 'PathToYourActionFunction', 'CssClass')

and your function must have just one parameter:

function yourFunction($primary_key) { // You don't have the $row parameter
}

This resolved my problem. Good day!


In Topic: Edit fileds not displaying correctly with Custom Query

09 September 2015 - 10:18 PM

 

Hello!

 

I not sure I understand your question...

 

In my example, I return an dropdown field in the callback_edit_tb1...

If I undertood correctly your question, yes, you should replace the $this->TB1_model->findAll() for the call to the function that will return the car models you want. So you can replace the options on '<option value="' . $data->id . '">' . $data->description . '</option>' by your results.​

 

 β€‹Is that what you asked? :)​

 

 

 


In Topic: Edit fileds not displaying correctly with Custom Query

09 September 2015 - 01:52 PM



   $this->grocery_crud->set_table('tb2');

   [...]

   $this->grocery_crud->fields('tbl1.column1, tbl2.column1, tbl2.column2'); //Put the names of the fields
   $this->grocery_crud->callback_edit_field('tbl1.column1', array($this, '_callback_edit_tb1_column1'))   ;

   $this->grocery_crud->callback_before_update(array($this, '_callback_before_update'));
   $this->grocery_crud->callback_after_update(array($this, '_callback_after_update'));


   [...]

   $this->grocery_crud->render();  

   [...]

}

//The callback edit function will return your input
//I made an example with a select, but you could just return an input
function _callback_edit_tb1_column1($value, $primary_key) {
   $input = '<select id="tb1.column" name="tb1.column">' //(the name attribute must be the same of your field)
   
   $results = $this->TB1_model->findAll(); //find the data you want
   
   if ($results) {
        foreach ($results as $data) {
             $input .= '<option value="' . $data->id . '">' . $data->description . '</option>'
        }
   }
   
   $input .= '</select>';
   return $input;
}

//callback_before_update
_callback_before_update($post_array, $primary_key) {

   $this->session->set_userdata('your_TB1_field_name', $post_array['your_TB1_field_name']);
   unset($post_array['your_TB1_field_name']);
   return $post_array;
}

//callback_after_update
_callback_after_update($post_array, $primary_key) {
   $field_value = $this->session->userdata('your_field_name');
   if ($field_value) {
      $this->db->where('tb2_column1', $primary_key);
      $this->db->update('tb1', array('tb1.column' => $field_value));
      $this->session->unset_userdata('your_field_name');

   }
} 

Hi! I did something like that in my case.. That's just a small example for you to have an idea of the thing..

 

I don't know if that's your case, but I hope it helps.

PS.: I'm not on my own computer, so I did not test this, but I think you'll be able to start from there..

 

=]