Validation Messages Don't Show for Related Models in CakePHP -


I have a set of models that looks like this

  • member
    • Member _ Address
    • Agents
      • Agent's Address

I also have a form which tries to update all these different models in one form. I am a bit new to this method of making a look in CakePHP, and I have trouble getting the verification error message to show in my form. Is happening

My form looks something like this:

  & lt ;? Php echo $ this- & gt; Form- & gt; Create ('member', array ('type' = & gt; 'file')) ;? & Gt; & Lt; Fieldset & gt; & Lt ;? Php echo $ this- & gt; Form- & gt; Input ('first_name'); Copy $ this- & gt; Form- & gt; Input ('last_name'); ? & Gt; & Lt; / Fieldset & gt; & Lt; Fieldset & gt; By & lt;? Copy $ this- & gt; Form- & gt; Input ('Subscriber Officer .0.LINE_1'); Copy $ this- & gt; Form- & gt; Input ('Member Official.c.City'); Echo $ $- this-> Form- & gt; Input ('MemberOfficer 0..STATE'); Echo $ $- this-> Form- & gt; Input ('Member.0.zip'); ? & Gt; & Lt; / Fieldset & gt; & Lt; Fieldset & gt; By & lt;? Echo $ $- this-> Form- & gt; Input ('subscriber official.1 .line_1'); Copy $ the-> gt; Form- & gt; Input ('Subscribers' .1.city'); Copy $ this- & gt; Form- & gt; Input ('MemberOfficer.1.State'); Copy $ this- & gt; Form- & gt; Input ('Member1.zip'); ? & Gt; & Lt; / Fieldset & gt; & Lt; Fieldset & gt; By & lt;? Echo $ $- this-> Form- & gt; Input ('Agent.0.agent', array ('type' => 'text')); Echo $ $- this-> Form- & gt; Input ('Agent.0.agency'); Echo $ $- this-> Form- & gt; Input ('Agent.0.email'); Copy $ this- & gt; Form- & gt; Input ('Agent.0.phone'); ? & Gt; & Lt; / Fieldset & gt; & Lt; Fieldset & gt; By & lt;? Copy $ this- & gt; Form- & gt; Input ('Agent.0.AgentAddress.line_1'); Copy $ this- & gt; Form- & gt; Input ('Agent.0.AgentAddress.city'); Copy $ this- & gt; Form- & gt; Input ('Agent.0.AgentAddress.state'); Copy $ this- & gt; Form- & gt; Input ('Agent.0.AgentAddress.zip'); ? & Gt; & Lt; / Fieldset & gt; & Lt ;? Php echo $ this- & gt; Form- & gt; End ('send') ;? & Gt;  

The essence of this form is a user-profile (member), in which there are two slots for the address, along with the contact information of "agent" ... agent model Agent and Agent Ginger I am using a lot of relationships for the membership, but only allows users to provide two addresses.

I am getting a verification message for the top-level member model, but I can not find the verification message for the related model. In my controller, I decided not to use save all, because member member and member address with 3 items, I will not be able to save anything if I leave the second member position (memberuddha1). So I changed the savings to save all, pushed the savings logic into the member's model, and I successfully returned a boolean value from my member-order-> update () call in the model for a sign of failure or failure.

How can I bounce validation error messages for member and agent model (agent and agent ginger)?

If you do not want to use savings all you can use it for verification purposes only If ($ this-> Members- & gt; Savings All ($--> Data, array 'valid' = & gt; 'only'))) { // Your custom saved function}

The problem with validation is that the errors should be linked to the appropriate form elements, and when you are using some custom save function, the member Address The associated errors are attached, when they have member address CITT Should be linked to.


Comments