Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to set nested associated Models
    primarykey
    data
    text
    <p>I'm trying to understand how to create nested data with <code>CakePHP</code> and <code>saveAssociated</code> method without success, I've wrote a model structure where a <code>Character</code> > <code>hasMany</code> > <code>PropertyGroup</code> and a <code>PropertyGroup</code> > <code>hasMany</code> ><code>Property</code>.</p> <p>How can I create a relation between PropertyGroup and it's Properties in the add view?</p> <pre><code>// Character Model echo $this-&gt;Form-&gt;input('name', array ('label' =&gt; false, 'value' =&gt; 'Character name')); echo $this-&gt;Form-&gt;input('description', array ('type' =&gt; 'textarea', 'label' =&gt; false, 'value' =&gt; 'Character description')); // PropertyGroup Model echo $this-&gt;Form-&gt;input('PropertyGroup.0.name', array ('label' =&gt; false, 'value' =&gt; 'Group name')); echo $this-&gt;Form-&gt;input('Property.0.name', array ('label' =&gt; false, 'value' =&gt; 'Property name')); echo $this-&gt;Form-&gt;input('Property.0.value', array ('label' =&gt; false, 'value' =&gt; 'Property value')); echo $this-&gt;Form-&gt;end('Add character'); </code></pre> <p>My problem starts if I'd like to create multiple <code>PropertyGroups</code>, so:</p> <pre><code>PropertyGroup.0.name Property.0.name Property.0.value Property.1.name Property.1.value PropertyGroup.1.name Property.0.name Property.0.value Property.1.name Property.1.value </code></pre> <p>How can I set the form to be compatible to multiple <code>PropertyGroups</code>?</p> <p>I can do it via javascript to like cloning via jQuery the inputs I need and incrementing the id, but I'm not sure how can I do it with <code>Properties</code>. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload