Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>i am also puzzled as to how a mandatory field:</p> <p><code>$this-&gt;addField('description')-&gt;type('text')-&gt;mandatory(true);</code></p> <p>end up being passed as a <strong>NULL</strong> value in your SQL insert string:</p> <p><code>(NULL, 'as', NULL, '', '', NULL, 2500, 25, 'enabled')</code></p> <p>ATK4 should already give a notification that this field is required and would never lead to an <code>update()</code> attempt if the required fields are still empty.</p> <p>do you have by any chance, a <code>beforeInsert()</code> or <code>beforeModify()</code> method defined that somehow manipulates this data prior to inserting?</p> <p>as for the <code>NULL</code> value for <code>category_id</code>, when adding a new entry, by default, no items are selected for both:</p> <p><code>$this-&gt;addField('category_id')-&gt;refModel('Model_Category')-&gt;mandatory(true);</code></p> <p>and</p> <p><code>$this-&gt;addField('picture_id')-&gt;refModel('Model_Picture')-&gt;mandatory(true);</code></p> <p>so when adding a new entry, the user has to explicitly select from the list first.</p> <p>for me, if all else fails, i rely on the beforeModify() method and throw a js()->fieldError notification:</p> <p>try inserting this in your model:</p> <pre class="lang-php prettyprint-override"><code>function beforeModify(&amp;$data){ if(empty($data['category_id'])){ $this-&gt;owner-&gt;owner-&gt;js()-&gt;atk4_form('fieldError','category_id', 'Select an category from the list')-&gt;execute(); exit; } } </code></pre> <p>please note that you may have to experiment on the <code>$this-&gt;owner-&gt;owner</code> to arrive at the MVCForm object.</p> <p>also, the <code>exit()</code> call is important to prevent the internal <code>render()</code> method from producing the HTML page and only produce the Javascript Chain.</p> <p>I hope this helps.</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.
    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