function rfq_items(){ $crud->columns('ItemId','Quantity','Remark'); $crud->fields('BillId','ItemId','Quantity','Remark'); $crud->display_as('ItemId','Item Id'); $crud->display_as('BillId','RFQ Id'); $crud->field_type('BillId','readonly'); $crud->field_type('Quantity','integer'); $crud->field_type('Remark','text'); $crud->callback_field('BillId',array($this,'callback_field_bill_id')); $crud->set_relation('ItemId', 'item', '{id}-{name}'); $crud->required_fields('BillId','ItemId','Quantity','Rate'); } function callback_field_bill_id($value = '', $primary_key = null){ $val = $this->uri->segment(3); return '<input id="field-BillId" name="BillId" type="text" value="'.$val.'" maxlength="50" style="width:462px" readonly>'; }
When I try to add new item, the add_new page opens as shown in attached image (note the auto-filled value in "RFQ Id" field). Now when I try to save the data, it gives me error in popup: "An error has occurred on insert."
Can anybody help to sort out the mistake in above code?