Your examples with date field are not the good example for the value
transformer.
If you store ex. the last name in the database with NULL or empty
value
and you want to get the value "not specified" on the textfield.
Would you write a subclass of sfWidgetFormInput or a subclass of a
sfStringValidator?
It would be cool, if I can write a value transformer and set it on a
form value:
class sfValueTransformerNotSpecified extends sfValueTransformer
{
public function getTransformedValue($value)
{
if (empty($value))
{
return "not specified";
}
return $value;
}
public function getReverseTransformedValue($value)
{
if ($value == "not specified")
{
return '';
}
return $value;
}
}
and in your sfForm:
public function configure()
{
$valueTransformerNotSpecified = new sfValueTransformerNotSpecified
();
$this->widgetSchema->setValueTransformer('first_name',
$valueTransformerNotSpecified);
$this->widgetSchema->setValueTransformer('last_name',
$valueTransformerNotSpecified);
$this->widgetSchema->setValueTransformer('description',
$valueTransformerNotSpecified);
// ...
}
Widget is the view, the validator validates the values and value
transformer transforms the value from model to view and back ...
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---