Hi Barry,

You can specify if the foreign key used in an association should be nullable or 
not:

    /**
     * @ManyToOne(targetEntity="SportingTeam")
     * @JoinColumn(name="team_id", referencedColumnName="id", nullable=TRUE)
     */
    private $sportingTeam;

I'm not sure about the form, this is not something of Doctrine.

PS: Doctrine itself doens't enforce properties to be "not null", but when the 
database is in sync with your mapping data, and you have a NOT NULL property, 
the database ofcourse will enforce this :)

--  
Jasper N. Brouwer
(@jaspernbrouwer)


On 28 April 2014 at 06:23:56, Barry Steele ([email protected]) wrote:
> I have an applciation with a large number of tables, which is no real issue.
>  
> I do however have the following problem:
>  
> Example
>  
>  
> InterestingPeople
>  
> id : identifier
> sporting_team: team_id Null, (Nb Null values are perfectly reasonable =
> might have no sporting affiliations)
>  
> ... other columns.
>  
>  
> sporting_team:
>  
> id: identifier
> name
>  
> Note. that the entries in the People table may have a sporting team, or not.
>  
> But if they do have a sporting team it must be in the Sporting Team table.
>  
> This is a perfectly reasonable RDBMS schema and is handled very nicely in
> SQL, etc.
>  
> I have tried to use "'DoctrineModule\Form\Element\ObjectSelect:" id build
> a drop down select, which works as expected.
>  
> But the Form will not validate as for some reason the form will not accept
> a null in that field.
>  
> I've seen a few posts about this but I would like to understand why this
> behaviour exists before committing any great effort to building the rest of
> the DBAL .
>  
> Does Doctrine try to enforce "NOT NULL" in this situation?
>  
> If so, is there any reason? How do I overwrite it?
>  
> Stay well,
> Barry


-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to