Note that there are some explanatory texts on larger screens.

plurals
  1. POCakePHP save failing with validation errors set but empty
    primarykey
    data
    text
    <p>A model that I am using with both TranslateBehavior and TreeBehavior is failing to save. I suspect it is something to do with one of these behaviors. Here's the data going in:</p> <pre><code>array( 'Category' =&gt; array( 'id' =&gt; '3252', 'parent_id' =&gt; null, 'sort_order' =&gt; '0', 'name' =&gt; array( 'eng' =&gt; 'english name', 'fra' =&gt; 'french name', 'deu' =&gt; 'german name', 'ita' =&gt; 'italian name', 'spa' =&gt; 'spanish name' ), ) ) </code></pre> <p>And <code>$this-&gt;Category-&gt;validationErrors</code> is:</p> <pre><code>array( 'parent_id' =&gt; array(), 'sort_order' =&gt; array() ) </code></pre> <p>There are no validation rules defined in the model. There is no beforeSave() or beforeValidate() method defined.</p> <p>I am not getting any validation errors displayed on screen, although all fields have the red "error" outline.</p> <p>Edit - the save operation is not getting as far as Category::beforeSave(). I created that function and it does not get run. It gets as far as Category::beforeValidate().</p> <pre><code> $validates = $this-&gt;Category-&gt;validates($this-&gt;request-&gt;data); debug($validates); $saved = $this-&gt;Category-&gt;saveAll($this-&gt;request-&gt;data); debug($saved); </code></pre> <p>In the above code, <code>$validates</code> is true, <code>$saved</code> is false. Category beforeSave is not called at any point in the above process. The validation seems to fail on the call to saveAll(). I need to use saveAll rather than save to save all translations at once (I am doing this elsewhere with another model with no problems).</p>
    singulars
    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.
 

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