Note that there are some explanatory texts on larger screens.

plurals
  1. POField not showing error in Agile Toolkit
    primarykey
    data
    text
    <p>trying to use the beforeSave hook with some server side validation and throwing a field error - and it is working ..... kind of ....</p> <p>There is an exception caused because it doesn't save as required and the base exception can be viewed with the right message if no field is defined. If I define field then I don't see the error popup or the error info on the crud form. </p> <p>To be clear, its not letting me save and throwing the exception. When I use <code>setField('fiscal_year')</code> Its still not saving as per the exception, its just not <strong>displaying</strong> the exception.</p> <p>Code below:</p> <pre><code>class Model_Finances extends Model_Table { public $table='finances'; function init() { parent::init(); $this-&gt;hasOne('Grant'); $this-&gt;addField('fiscal_year')-&gt;datatype('int'); $this-&gt;addField('requested')-&gt;datatype('money'); $this-&gt;addField('committed')-&gt;datatype('money'); $this-&gt;addField('spent')-&gt;datatype('money'); $this-&gt;getField('grant')-&gt;hidden(true); $this-&gt;addHook('beforeSave',$this); } function beforeSave($model){ $exist = $this-&gt;api-&gt;db-&gt;dsql() -&gt;table($this-&gt;table) -&gt;field('count(1)') -&gt;where('grant_id', 2) //manually set ID for testing. -&gt;where('fiscal_year', $model['fiscal_year']) -&gt;do_getOne(); // Validate fiscal year before saving if($exist[0]) { throw $this-&gt;exception('Fiscal year for this grant already exists')-&gt;setField('fiscal_year'); } } } </code></pre> <p>How it's being used:</p> <pre><code> $finances = $grant-&gt;ref('Finances'); $finances-&gt;getField('fiscal_year')-&gt;setValueList($this-&gt;fiscalYears)-&gt;mandatory(true); $crud=$tabs-&gt;addTab('Finances')-&gt;add('CRUD'); $crud-&gt;setModel($finances); if($crud-&gt;grid)$crud-&gt;grid-&gt;addTotals(array('requested', 'committed', 'spent')); </code></pre>
    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