Flourish PHP Unframework
This is an archived copy of the forum for reference purposes

Message: No fields or rules have been added for validation

posted by mungiu 8 years ago

How can i get rid of that, i make some dinamic crud and i add validation only in table who have some fields but same script is used by all tables and for some of them i don't have fields that requre this validation.

and related on this question how can i get all validation in same error message seted by fvalidation and that seted by form automaticaly depends on database fields.

posted by mungiu 8 years ago

I would put an if statement around your validation:

$fields = $object->getValidationFields();
if ($fields) {
    $validator = new fValidation();
    $validator->addRequiredFields($fields);
    $validator->validate();
}

I'm not positive what you are asking in your second question, but I'll try to answer it. If you need to combine validation sources, you can use ->validate(TRUE), merge the validation arrays and then pass them to fValidationException.

$validator = new fValidation();
$validator->addRequiredFields($fields);

$messages = array_merge(
    $validator->validate(TRUE),
    $active_record->validate(TRUE)
);

if ($messages) {
    throw new fValidationException('The following problems were found:', $messages);
}
posted by wbond 8 years ago

$fields = $object->getValidationFields(); what is the object, active record object? any way it can help me, beause i ste the form field dinamically , before i instanciate class fvalidation, and after ai use validate() so i cant put that if, any way i put a dummy $validator->addEmailFields('email') even that field doesnt exist. and now have what to validate.

posted by mungiu 8 years ago

That was just an example. You mentioned you are using some dynamic list of fields to validate.

It is hard for me to understand the rest of your question due to the spelling errors and grammar. Perhaps if you post some of your code I can get a better idea of what you are trying to do.

posted by wbond 8 years ago