cakephp one form, multiple models, not displaying one model's validation messages

前端 未结 2 1114
鱼传尺愫
鱼传尺愫 2020-12-28 18:44

I have a registration form and I am creating a record in both User and Identity tables (a user hasMany identities)

the form looks like this



        
相关标签:
2条回答
  • 2020-12-28 19:09

    hasMany model's fields should be as array (when combined with parent model), see .0 added between field names

    echo $this->Form->input('Identity.0.name');
    echo $this->Form->input('Identity.0.surname');
    ...
    echo $this->Form->input('Identity.0.email');
    
    0 讨论(0)
  • 2020-12-28 19:19

    One answer I found was on this page much about the same problem. The solution was to add the validate attribute to saveAll

    if($this->Member->saveAll($this->data, array('validate'=>'only'))){
       //your custom save function
    }
    
    0 讨论(0)
提交回复
热议问题