Hi everybody,
I just ran into this and thought I'd post it here before filing a
ticket on it:
If you have a form with optional data and required data it would be
nice if there was a method like sfFormField::isRequired. This would
allow the easy adding of for example stars to the required fields. A
behavior that is pretty common.
The function could extract the value from the validator on that field.
For now I have implemented this in my own subclassed sfForm like this.
Hopefully I'm not the only one who would like to see this implemented
on sfFormField:-D
class MyForm extends sfForm
{
private $_validatorFields;
/**
* Check if a field is required or not
*/
public function isRequired ($field)
{
if (is_null($this->_validatorFields))
{
$this->_validatorFields = $this->validatorSchema->getFields();
}
if ( ! array_key_exists($field, $this->validatorFields))
{
return FALSE;
}
return $this->_validatorFields[$field]->getOption('required');
}
}
Regards,
Marijn
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en
-~----------~----~----~----~------~----~------~--~---