Why readonly field dont work if is required field?
- Single Page
Posted 28 May 2012 - 14:56 PM
why I get field required message validation on edit form? the field tid is readonly on edit form.
$this->grocery_crud->fields('tid','local_id','nome','data_instalacao');
$this->grocery_crud->required_fields('tid','local_id','nome','data_instalacao');
if( $operation == 'add') //work
{
$this->grocery_crud->set_rules('tid', 'ID','required|is_unique[carcacas.tid]');
}
else if ( $operation == 'edit') //get validation required error
{
$this->grocery_crud->change_field_type('tid','readonly'); //show me field readonly
}
this work on add form, but when edit form show readonly field and validation error message "The field ID is required!".
I'm using current version.
thanks,
groceryCRUD is fantastic, congratulations
best regards
Posted 28 May 2012 - 16:27 PM
Posted 28 May 2012 - 18:01 PM
$this->grocery_crud->fields('tid','local_id','nome','data_instalacao');
if( $operation == 'add')
{
$this->grocery_crud->set_rules('tid', 'ID','required|is_unique[carcacas.tid]');
$this->grocery_crud->set_rules('local_id', 'Local','required');
$this->grocery_crud->set_rules('nome', 'Nome','required');
$this->grocery_crud->set_rules('data_instalacao', 'Data Instalação','required');
//validation dont work on commit form
}
else if ( $operation == 'edit')
{
$this->grocery_crud->set_rules('local_id', 'Local','required');
$this->grocery_crud->set_rules('nome', 'Nome','required');
$this->grocery_crud->set_rules('data_instalacao', 'Data Instalação','required');
$this->grocery_crud->change_field_type('tid','readonly');
//validation dont work on commit form
}
i need only see tid field readonly in edit mode and required validation only add method, I dont understand when set_rules replace rules of required_fields function, I tried before and after...
thanks
best regards
Posted 28 May 2012 - 20:16 PM
if( $operation == 'add' || $operation == 'insert' || $operation == 'insert_validation')//Change this line here <-----------------------------------------------------
{
$this->grocery_crud->set_rules('tid', 'ID','required|is_unique[carcacas.tid]');
$this->grocery_crud->set_rules('local_id', 'Local','required');
$this->grocery_crud->set_rules('nome', 'Nome','required');
$this->grocery_crud->set_rules('data_instalacao', 'Data Instalação','required');
}
elseif( $operation == 'edit' || $operation == 'update' || $operation == 'update_validation') //Change this line here <-----------------------------------------------------
{
$this->grocery_crud->set_rules('local_id', 'Local','required');
$this->grocery_crud->set_rules('nome', 'Nome','required');
$this->grocery_crud->set_rules('data_instalacao', 'Data Instalação','required');
$this->grocery_crud->change_field_type('tid','readonly');
}
Posted 28 May 2012 - 20:44 PM
best regards!