What yes ? So extend it and that's it :) I don't see any easier other option. You can extend phalcons' classes. For example you can create MyForm like this:
class MyForm extends Form
{
private $groups;
public function initialize()
{
$this->groups = array();
// adding fields
// creating groups
$this->addValidationGroup('country',[
'someField'=>new PresenceOf(array('message' => 'The name is required')),
'someField1'=>new PresenceOf(array('message' => 'The name is required')),
'someField2'=>new PresenceOf(array('message' => 'The name is required')),
]);
$this->addValidationGroup('default',[
'someField3'=>new PresenceOf(array('message' => 'The name is required')),
]);
$this->setValidationGroups('default');
}
public function addValidationGroup($name,$arrayOfValidators)
{
$this->groups[$name] = $arrayOfValidators;
}
private function setValidationGroup($name)
{
if(isset($this->groups[$name])){
foreach($this->groups[$name] as $field => $validator){
if($this->has($field)){
$this->get($field)->addValidator($validator);
}
}
}
}
public function setValidationGroups($validationGroups)
{
if(is_array($validationGroups)){
foreach($validationGroups as $name){
$this->setValidationGroup($name)
}
}
else if(is_string($validationGroups)){
$this->setValidationGroup($validationGroups)
}
else{
throw new Exception();
}
}
}
Well i guess i could possibly add to phalcon Form some code like this - but is it really necessary ?