⚠ 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

Please, help me see where I'm wrong



matiasnabarro@gmail.com
  • profile picture
  • Member

Posted 07 March 2019 - 12:51 PM

	public function mate_detalle($id)
	{

		//echo $id;

		$crud = new grocery_CRUD();
		$crud->set_table("ope_materiales");
		$crud->set_subject("Materiales");

    $crud->where('tbl_opes_id',$id);

    $this->id_operacion=$id;
		
    $crud->callback_before_insert(array($this,'set_ope_id_callback'));

		$crud->fields(["tbl_opes_id","tbl_materiales_id", "cantidad", "tbl_unidades_id"]);
		
        // Show in

		$crud->add_fields(["tbl_materiales_id", "cantidad", "tbl_unidades_id","tbl_opes_id"]);
		$crud->edit_fields(["tbl_materiales_id", "cantidad", "tbl_unidades_id","tbl_opes_id"]);
		$crud->columns(["tbl_materiales_id", "cantidad", "tbl_unidades_id"]);
        
        // Fields type
		$crud->field_type("tbl_opes_id", "hidden");
        $crud->field_type("id", "integer");
		$crud->set_relation("tbl_opes_id", "tbl_opes","parte_serv");
		$crud->set_relation("tbl_materiales_id", "tbl_materiales", '{material_codigo} - {material_nombre}');
		$crud->field_type("cantidad", "integer");
		$crud->set_relation("tbl_unidades_id", "tbl_unidades", '{unidad_abrev} ({unidad})');

		// Relation n-n

		// Display As
		$crud->display_as("tbl_opes_id", "Operaci&oacuten");
		$crud->display_as("tbl_materiales_id", "Material");
		$crud->display_as("cantidad", "Cantidad");
		$crud->display_as("tbl_unidades_id", "Unidad");

		// Unset action
		$crud->unset_clone();

		$output = $crud->render();

    $this->load->view('/template/header', $output);
    $this->load->view('/template/navbar');
    $this->load->view('/template/gc');    
    $this->load->view('/template/footer');

	}

	function set_ope_id_callback($post_array)
	{
        $post_array['tbl_opes_id'] =$this->id_operacion;
 		return $post_array;
	}

I can't see where is the error. I need to hide "tbl_opes_id" in edit and add views but I can't do it. If I take off the field in "add_fields" or "edit_fields", the data is not inserted and shows me an error. $crud->field_type("tbl_opes_id", "hidden") doesn't works in the way I use it.  Thanks in advance!. PS: I'm using bootstrap-V4 theme with 1.6.2 version of GC