Reputation: 411
In cakePHP how would you achieve date validation when placing your validation statement inside the controller. could I put a second if statement after the first validation statement? i am not sure how you'd make it validate as systemdate is before or equal to the expiry date
if($this->Invoice->validates(array('fieldList'=>array('Relationship.partyone','Relationship.active'))))
{
$this->Invoice->create();
if ($this->Invoice->saveAll($this->request->data,array('validate'=>false)))
{
$this->Session->setFlash('The invoice has been saved');
Upvotes: 0
Views: 2523
Reputation: 8461
Probably you need custom validation for date date comparison
In Model
var $validate = array(
'date' => array(
'rule' => array('datevalidation', 'systemDate' ),
'message' => 'Current Date and System Date is mismatched'
)
);
function datevalidation( $field=array(), $compare_field=null )
{
if ($field['date'] > $compare_field)
return TRUE;
else return FALSE;
}
In Controller
if($this->Invoice->validates(array('fieldList'=>array('Relationship.partyone','Relationship.active',Relationship.date))))
Upvotes: 1