Hi!
I am trying to add multiple items (products) and generate a field by each item to let me add a quantity.
I was searching for examples on internet but I'm stuck since several days with this, hope can help me.
Tahnks in advance! :)
Here is my code
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class DocumentosElab extends CI_Controller { function __construct() { parent::__construct(); $this->template->set_layout('layout.php'); $this->load->database(); $this->load->library('grocery_crud'); $this->load->helper('url'); $this->load->library(array('session')); $this->load->model(array('CI_auth', 'CI_menu')); $this->load->helper(array('html','url')); } function index() { } function documentoselab_v() { if($this->CI_auth->check_logged()===FALSE) redirect(base_url().'index.php/login/'); else{ $data['title'] = 'Area Restringida'; $data['menu_top'] = $this->CI_menu->menu_top(); $data['body'] = '<div style="padding:10px;">Usuario logueado</div>'; echo $this->input->post('username'); $this->load->view('_output_html', $data); } $this->load->view('layouts/header'); $this->load->view('layouts/menu'); try{ $crud = new grocery_CRUD(); $crud->set_theme('datatables'); $crud->set_table('documentos'); $crud->set_subject('documentos'); $crud->set_language('spanish'); $crud->required_fields( 'IdDocumento', 'IdProveedor' ); $crud->columns( 'IdProveedor', 'DocFecha' ); $crud->unset_fields('DocCompr');//, 'hidden', 0); //deshabilitado $crud->field_type('DocPuesto', 'hidden', 0); //escondido $crud->field_type('DocNumero', 'hidden', 0); $crud->field_type('DocFechaAlta', 'hidden', 0); $crud->field_type('DocPc', 'hidden', 0); $crud->field_type('DocFecha', 'hidden', 0); $crud->field_type('DocObservacion', 'hidden', 0); $crud->field_type('DocUsuario', 'hidden', 0); $crud->display_as('IdProveedor','Proveedor'); $crud->display_as('DocFecha','Fecha'); $crud->display_as('DocObservacion','Observación'); $crud->set_relation('IdProveedor','proveedores', 'ProvRSocial'); // I get multiple items here but I think I'm going to need something different for what I need $crud->set_relation_n_n('Productos', 'docproductos', 'productos', 'IdDocumento', 'IdProducto', 'ProdDescripcion', 'priority'); $output = $crud->render(); // and here I can generate a field but I need one by item $crud->add_fields('my_field'); $crud->change_field_type('my_field', 'text'); $crud->callback_edit_field('my_field',array($this,'callback_my_field')); function callback_my_field() { return '+30 <input type="text" maxlength="50" value="cantidad" name="Cantidad" style="width:462px">'; } $this->load->view('documentoselab/documentoselab_v', $output); }catch(Exception $e){ show_error($e->getMessage().' --- '.$e->getTraceAsString()); } $this->load->view('layouts/footer'); } } ?>