我有一個基於名爲'factor'的模型類的一般形式。在這種形式下,有一個名爲'customer'的嵌入式表單,它基於名爲'customer'的模型類。如何防止symfony中的表格保存?
這裏是我的schema.yml的相關部分:
factor:
actAs:
Timestampable: ~
columns:
customer_id: {type: bigint}
final_sum: {type: Integer}
relations:
customer: {local:customer_id, foreign:id, alias: customer, foreignAlias:factors}
customer:
columns:
name: {type: string(255), notnull:true, unique:true}
當用戶提交的一般形式,我檢查,如果在客戶表存在CUSTOMER_NAME,如果是這樣,我想嵌入的形式「顧客」不能保存,因爲它會導致列唯一性的錯誤! 相反,我應該將customer_id設置爲已存在於db中的客戶的id。 我該如何管理?
推進或學說? – Soundz
學說[評論必須至少15個字符長:D] – Ehsan
對不起,我承認我不能幫助你的教義,但只是提到它:推動會做這種行爲隱含。如果條目存在,則更新它,如果不存在則創建它 – Soundz