Element_OphTrOperationnote_Cataract::beforeValidate PHP Method

beforeValidate() public method

Validate IOL data if IOL is part of the element.
public beforeValidate ( ) : boolean
return boolean
    public function beforeValidate()
    {
        $iol_position = OphTrOperationnote_IOLPosition::model()->findByPk($this->iol_position_id);
        if (!$iol_position || $iol_position->name != 'None') {
            if (!$this->iol_type_id) {
                $this->addError('iol_type_id', 'IOL type cannot be blank');
            }
            if (!isset($this->iol_power)) {
                $this->addError('iol_power', 'IOL power cannot be blank');
            }
            /* elseif (!is_numeric($this->iol_power) || strlen(substr(strrchr($this->iol_power, "."), 1)) > 2 || ((-999.99 > $this->iol_power) || ($this->iol_power > 999.99))) {
                   $this->addError('iol_power', 'IOL power must be a number with an optional two decimal places between -999.99 and 999.99');
                 }
                 elseif (strlen(substr(strrchr($this->iol_power, "."), 1)) > 2) {
                   $this->addError('iol_power', 'IOL power must be a number with an optional two decimal places between -999.99 and 999.99');
               } elseif ((-999.99 > $this->iol_power) || ($this->iol_power > 999.99)) {
                   $this->addError('iol_power', 'IOL power must be a number with an optional two decimal places between -999.99 and 999.99');
                 } */
        }
        return parent::beforeValidate();
    }