Suppose I have a table like this:
| Field | Type | Null | Key | Default |
+-------------------+--------------+------+-----+---------+
| id | int(11) | NO | PRI | NULL |
| subject | varchar(255) | NO | | NULL |
| status_id | int(11) | NO | MUL | NULL |
| reference_id | int(11) | NO | MUL | NULL |
In the schema.yml, these fields were defined like this:
sources_updates:
id: ~
subject: { type: varchar(255), required: true }
status_id : { type: integer, foreignTable: sources_status,
foreignReference: id, required: true }
reference_id: { type: integer, foreignTable:
sources_reference, foreignReference: id, required: true }
created_at: ~
updated_at: ~
For a particular form, I don't need status_id or reference_id, so I
unset() them in the form's configure() method.
Since the schema says they are required, and the form base class also
says they are required, I now need to ensure that they won't be
required, so I do this in configure():
$this->validatorSchema['reference_id'] = new sfValidatorPropelChoice
(array('model' => 'SourcesUpdates', 'column' => 'id', 'required' =>
false));
$this->validatorSchema['status_id'] = new sfValidatorPropelChoice(array
('model' => 'SourcesUpdates', 'column' => 'id', 'required' =>
false));
Now, when creating a new record through the form, I get this error
(which I think involves one of the indexes):
Unable to execute INSERT statement. [wrapped: SQLSTATE[23000]:
Integrity constraint violation: 1452 Cannot add or update a child row:
a foreign key constraint fails (`hotsources/news_reports`, CONSTRAINT
`news_reports_FK_7` FOREIGN KEY (`status_id`) REFERENCES
`sources_status` (`id`))]
How do I get around this error?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony users" 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-users?hl=en
-~----------~----~----~----~------~----~------~--~---