Hello there!
First, I'm sorry if this is a noobish question.
Well, I'm quite sure it is.
I'm trying to make a gallery of images for a website;
Every "case" might have it's own images.
So:
- Table cases have some columns. One of those is called case_id
- I was able to create a custom action called gallery_add, and send the case_id along with the URL
- I'm able to list only the records in the table "case_gallery" where the case_id equals the case_id sent in the URL (via $_GET)
Here is my doubt:
the only way I can input the correct case_id in the new record is by typing it manually in the input.
If I try to send the correct $id through the gallery_add, it doesn't go. Probably because the "add record" doesn't send any info?
Sorry for this noobish question.
Here is my code:
public function cases() // (cases listing page)
{
if($this->session->userdata('logged_in')) #se tiver feito login, carrega a página
{
$this->grocery_crud->set_table('cases');
$this->grocery_crud->columns('case_nome','case_miniatura', 'case_slideshow_antes','case_slideshow_depois','case_texto');
$this->grocery_crud->display_as('case_nome','Nome');
$this->grocery_crud->display_as('case_miniatura','Miniatura');
$this->grocery_crud->display_as('case_slideshow_antes','Imagem Antes');
$this->grocery_crud->display_as('case_slideshow_depois','Imagem Depois');
$this->grocery_crud->display_as('case_texto','Texto (Soluções utilizadas)');
$this->grocery_crud->set_field_upload('case_miniatura','../img');
$this->grocery_crud->field_type('case_texto','text');
$this->grocery_crud->set_field_upload('case_slideshow_antes','../img');
$this->grocery_crud->set_field_upload('case_slideshow_depois','../img');
$this->grocery_crud->add_fields('case_nome', 'case_miniatura','case_slideshow_antes','case_slideshow_depois','case_texto');
$this->grocery_crud->edit_fields('case_nome','case_slideshow_antes','case_slideshow_depois','case_texto');
$this->grocery_crud->add_action('Galeria', '', '','ui-icon-image',array($this,'galeria'));
$output = $this->grocery_crud->render();
$this->_example_output($output);
} #else, manda pra página de login.
else
{
//If no session, redirect to login page
redirect('login', 'refresh');
}
}
public function galeria($primary_key , $row)
{
return site_url('home/galeria_add').'?case_id='.$row->case_id;
}
public function galeria_add()
{
if (isset($_GET['case_id'])) {
$id = $_GET['case_id'];
}
$this->grocery_crud->set_table('case_galeria');
$this->grocery_crud->columns('foto_id','case_id', 'galeria_imagem_endereco');
$this->grocery_crud->set_field_upload('galeria_imagem_endereco','../img');
$this->grocery_crud->field_type('case_id', 'hidden', $id);
$this->grocery_crud->add_fields('case_id', 'galeria_imagem_endereco');
$this->grocery_crud->edit_fields('galeria_imagem_endereco');
if (isset($_GET['case_id'])) {
$this->grocery_crud->where('case_id', $_GET['case_id']);
}
$output = $this->grocery_crud->render();
$this->_example_output($output);
}
I'm very thankful for any help provided!