나는 optionnal 인 입력이있는 양식을 가지고 있지만 외래 키이고 Doctrine이 오류를 표시하기 때문에 사용자가 입력하지 않으면 양식을 유효하게 할 수 없습니다.외래 키를 null로 설정하는 방법은 무엇입니까? (symfony)
SQLSTATE[HY000]: General error: 1452 Cannot add or update a child row: a foreign key constraint fails (`logements`.`bail`, CONSTRAINT `bail_ibfk_3` FOREIGN KEY (`locataire2`) REFERENCES `locataire` (`nud`) ON DELETE CASCADE ON UPDATE CASCADE)
내가 phpMyAdmin을 동일한 요청을 시도하고 제대로 작동 : 나는 외래 키가 null로 설정할 수 있습니다.
외래 키를 null로 설정하고 Doctrine 오류없이 양식을 유효하게하려면 어떻게해야합니까?
편집
Bail:
connection: doctrine
tableName: bail
columns:
id:
type: integer(2)
fixed: false
unsigned: true
primary: true
autoincrement: true
locataire1:
type: string(20)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
locataire2:
type: string(20)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
logement:
type: integer(2)
fixed: false
unsigned: true
primary: false
notnull: false
autoincrement: false
datedeb:
type: date(25)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
datefin:
type: date(25)
fixed: false
unsigned: false
primary: false
default: '0000-00-00'
notnull: false
autoincrement: false
colloc:
type: integer(4)
fixed: false
unsigned: false
primary: false
default: '0'
notnull: false
autoincrement: false
bailglissant:
type: string(12)
fixed: false
unsigned: false
primary: false
default: 'Non spécifié'
notnull: false
autoincrement: false
relations:
Locataire:
local: locataire1
foreign: nud
type: one
Logement:
local: logement
foreign: id
type: one
Locataire_3:
class: Locataire
local: locataire2
foreign: nud
type: one
스키마 정의와 양식을 붙여주십시오. 필드가 실제로 선택 사항으로 정의 된 경우 그러한 메시지를 가져서는 안됩니다. 데이터베이스에서 오류가 발생하므로 doctrine이 '0'을 넣으려고합니다. –
내 양식의 위젯은 "locataire2" – Elorfin