Can i model validate a field that dose not exist in the database. It’s not working for the following code
Model
'agree' => array(
'comparison' => array(
'rule' => array('comparison', 'equal to', 1),
'message' => 'Accept the Proposal',
'allowEmpty' => false,
//'required' => true,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
),
.
view
<div class="input checkbox">
<input type="hidden" name="data[Season][agree]" id="SeasonAgree_" value="0">
<input type="checkbox" name="data[Season][agree]" value="1" id="SeasonAgree">
<label for="SeasonAgree"></label> Seasons Proposal displayed is correct
</div>
You can validate a field which is not in the database.
e.g. In a register form you can validate “I accept user terms” field and don’t save this value on the database.
In your code you’re validating “accept” instead “agree”. In fact, you have two inputs with the same name (
"data[Season][agree]"), it could be a problem.