How to autogenerate value and show in Add form as readonly field
- Single Page
Posted 12 March 2012 - 10:51 AM
We have a Employee Table and we want to auto-generate the Employee Code and show it in the add form as read-only in the Employee Code field
Kindly can you guide us how we can achieve this in grocery
Thanks
Kapil Arora
Posted 12 April 2012 - 17:42 PM
function example_callback_edit_field(){
$crud = new grocery_CRUD();
$crud->set_table('offices');
$crud->set_subject('Office');
$crud->required_fields('city');
$crud->columns('city','country','phone','addressLine1','postalCode');
$crud->callback_edit_field('phone',array($this,'example_callback_1'));
$output = $crud->render();
$this->_example_output($output);
}
function example_callback_1($value, $primary_key)
{
return "<b>".$value."</b>";
}
Posted 22 April 2012 - 14:02 PM
This seems not to work if you use a relation as in i.e. company_id => company_name
Kind Regards, Simons
Posted 22 April 2012 - 15:14 PM
Posted 22 April 2012 - 19:09 PM
Thanks for that link. I ended up using hidden fields, since the fields in question are foreign keys whih should not be edited in the given situation. So now the add and edit works.
I have actually coded most of the vital parts of the project backend in ~200 lines of code. This tool really rocks!
I found a kind of workaround for master detail: add_action
Best Regards, PsimonS