⚠ 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 is an archived forum. ⚠

  •     

profile picture

callback_after_insert



Lucas

Lucas
  • profile picture
  • Member

Posted 08 March 2012 - 15:32 PM

No Work function nombre_etapas, anybody can help me ?

function proyectos_etapas_crud() {
$crud = new grocery_CRUD();
$crud->set_table('fs_etapa');
$crud->set_theme('flexigrid');
$crud->set_subject('Etapas');
$crud->unset_columns('id');
$crud->required_fields('etapa_fecha_fin', 'etapa_fecha_inicio');
$crud->set_relation('fs_proyecto_id', 'fs_proyecto', 'proyecto_nombre');
$crud->set_relation('fs_definicion_etapa_id', 'fs_definicion_etapa', 'definicion_etapa_nombre');
$crud->display_as('fs_proyecto_id', 'Proyecto');
$crud->display_as('fs_definicion_etapa_id', 'Etapa');
$crud->display_as('etapa_fecha_inicio', 'Fecha de Inicio');
$crud->display_as('etapa_fecha_fin', 'Fecha de Finalización');
$crud->callback_after_insert(array($this, 'nombre_etapas'));
$crud->callback_after_update(array($this, 'nombre_etapas'));
$output = $crud->render();
$this->_example_output($output);
}

function nombre_etapas($post, $primary_key_value) {

$this->load->model('grocery_heredacion');
$query = $this->grocery_heredacion->getNombre_etapa($post['fs_definicion_etapa_id'])->row();
$this->grocery_heredacion->updateEtapa($post['id'], $query);
}

Lucas

Lucas
  • profile picture
  • Member

Posted 08 March 2012 - 15:33 PM

[b]this is the esctructure of model[/b]

class Grocery_heredacion extends CI_Model{

function __construct() {
parent::__construct();
}

function getNombre_etapa($id) {

$this->db->where('id', $id);
$query = $this->db->get('fs_definicion_etapa');
if ($query->num_rows == 1) {
return $query;
} else {
return false;
}
}

function updateEtapa($id, $datos) {
$this->db->where('id', $id);
$this->db->update('fs_etapa', array('etapa_nombre_heredado' => $datos->definicion_etapa_nombre, 'id' => '5'));
}
}

Lucas

Lucas
  • profile picture
  • Member

Posted 08 March 2012 - 15:47 PM

[size=5][b]the solution[/b][/size]


function nombre_etapas($post, $primary_key_value) {

$this->load->model('grocery_heredacion');
$query = $this->grocery_heredacion->getNombre_etapa($post['fs_definicion_etapa_id'])->row();
$this->grocery_heredacion->updateEtapa($primary_key_value, $query);
}