Hi, I think the reference should be validated but not necessarily the whole entity the reference points to.
Regards, Dennis On Sunday, April 17, 2011 10:36:43 AM UTC+2, Bernhard Schussek wrote: > > Hi Matt, > > The problem is that by default the data of each field is validated. For the > entity field this is the selected entity. Does it make sense to generally > disable validation for entity fields? > > Bernhard > > Am 16.04.2011 21:38 schrieb "Matt Johnston" <ma...@mjohnston.com>: > > I have two entities that are joined by a ManyToOne relation. Each > entity has it's own set of validators. When I submit a form for the > one object, the related object is also being validated. Is there any > way that the related object can not be validated? > > Here is an example, I am using Symfony2 PR11: > > class User { > ... > /** > * @orm:Column(type="string",nullable=false, unique=true) > * @assert:NotBlank() > */ > protected $name; > > /** > * @orm:ManyToOne(targetEntity="City") > * @orm:JoinColumn(name="city_id", > referencedColumnName="id",nullable=false) > * @assert:NotNull() > */ > protected $city; > > } > > class City { > ... > /** > * @orm:Column(type="string",nullable=false) > * @assert:NotBlank() > */ > protected $name; > > } > > In my UserForm configure() I add a reference to the City: > > $this->add(new EntityChoiceField('city', array( > 'em' => $em, > 'class' => 'MyBundle\Entity\City', > 'property' => 'name' > ))); > > The form displays correctly and creates a drop down list of all > existing cities pulled from the database. When I submit my UserForm > and validate it, I get errors that the city is missing a name. Why is > the validation propagating down to the related object? All the user object > needs to > know is if the city id is present and it doesn't need all the > additional fields for the city. > > -- > 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 users" group. > To post to this group, send email to symfon...@googlegroups.com > To unsubscribe from this group, send email to > symfony-user...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/symfony-users?hl=en > > -- 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 users" group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en