我有一个基于名为“因子”的模型类的通用形式。在该表单中,有一个名为“customer”的嵌入式表单,它基于名为“customer”的模型类。
这是我的 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 设置为数据库中已经存在的客户 ID。我该如何管理?