I dont think using a getter would solve the problem, as the getter
should always return the value regardless of whether the hypothetical
"field_enabled" flag is true or false.

the other thing I can think of is overloading the form class bind
method and strip the validation rules conditionally -- but not sure
how easy this will be.


My actual use case is:

class SomeEntity
{
  protected $field1 = 'somevalue';
  protected $field2 = 'someOthervalue';
  protected $field3 = 'andAnotherOne';

  protected $enabledList = array('field1', 'field2');
}

then the validation rule:

  if (in_array($field, $enabledList)) { // apply validation }


On 14 February 2011 01:00, Christophe COEVOET <[email protected]> wrote:
> Le 14/02/2011 01:39, Konstantin Kudryashov a écrit :
>
> You can validate not only class attributes, but methods itself. It means,
> that you can create your own method with custom logic, that will return
> true/false in different cases and you can link Boolean validator to that
> method's return value.
>
> To be exact you can only validate the methods whose name begins with "is" or
> "get" as the validator only allows validating getters. See
> http://docs.symfony-reloaded.org/master/guides/validator/constraints.html#getters
> for the doc.
>
> --
> Christophe | Stof
>
> --
> If you want to report a vulnerability issue on symfony, please send it to
> security at symfony-project.com
>
> 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
>



-- 
Dan Leech

Web Developer
www.dantleech.com

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

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

Reply via email to