validate::unique
validate::unique
rrzavaleta
Posts: 78Questions: 52Answers: 2
II can not validate that the field is required to use the Validate :: unique
Field::inst( 'ING_ASEG_BANCO.CUENTA_BANCO')->validator( 'Validate::unique', array(
'required'=>true,
'message'=>'duplicado',)),
works but allows me to save empty fields .
the ING_ASEG_BANCO.CUENTA_BANCO field is named so because it is part of a table that does a join.
$data =Editor::inst( $db, 'ING_ASEG_BANCO' )
->pkey( 'ING_ASEG_BANCO.ID')
->fields(
Field::inst( 'ING_ASEG_BANCO.ID'),
Field::inst( 'ING_ASEG_BANCO.ID_ASEGURADORA'),
Field::inst( 'ING_ASEG_BANCO.ID_BANCO') ->validator( 'Validate::notEmpty')
->getFormatter( 'Format::CapitaliseFirstLetter' )
->setFormatter( 'Format::CapitaliseFirstLetter' ),
Field::inst( 'ING_ASEG_BANCO.NUM_SUCURSAL')->validator( 'Validate::numeric',array('required'=>true) )
->getFormatter( 'Format::CapitaliseFirstLetter' )
->setFormatter( 'Format::CapitaliseFirstLetter' ),
Field::inst( 'ING_ASEG_BANCO.NOM_SUCURSAL') ->validator( 'Validate::notEmpty')
->getFormatter( 'Format::CapitaliseFirstLetter' )
->setFormatter( 'Format::CapitaliseFirstLetter' ),
Field::inst( 'ING_ASEG_BANCO.CUENTA_BANCO')->validator( 'Validate::unique', array(
'required'=>true,
'message'=>'duplicado',)),
// ->getFormatter( 'Format::CapitaliseFirstLetter' )
//->setFormatter( 'Format::CapitaliseFirstLetter' ),
Field::inst( 'ING_ASEG_BANCO.CLABE')->validator( 'Validate::minMaxLen', array(
'required'=>true,
'min' => 18,
'max' => 18,
'message' => 'Cadena permitida de 18 caracteres',
) ),
Field::inst( 'ING_ASEG_BANCO.F_MODIFICACION')->set( false )
->getFormatter( 'Format::date_sql_to_format', 'D, jS F Y' ),
Field::inst( 'ING_BANCO.NOM_BANCO' )
)
->leftJoin( 'ING_BANCO', 'ING_BANCO.ID_BANCO', '=', 'ING_ASEG_BANCO.ID_BANCO' )
->process( $_POST )
->data();
if ( ! isset($_POST['action']) ) {
// Get a list of sites for the `select` list
$data['ING_BANCO'] = $db
->selectDistinct( 'ING_BANCO', 'ID_BANCO as value, NOM_BANCO as label' )
->fetchAll();
}
echo json_encode( $data );
I just need to validate that the field is required and not allow saving the nullo field
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi,
Thanks for letting me know about this - there is a bug in the
unqiue
validation method that is causing this problem. In theValidate.php
file if you locate theunique
method (it should be right at the end of the file), immediately after the$cfg
variable is defined, could you add the following please:That should address this problem.
The fix will be in the next 1.4 beta release which is due out soon.
Regards,
Allan
Hi allan .
I worked your only solution that relocate . in the end I stayed follows
thx