<?php

namespace frontend\models;

use Yii;
use yii\base\Model;

/**
 * ContactForm is the model behind the contact form.
 */
class SubscribeForm extends Model
{
    public $idCustomer;
    public $token;
    public $subscribe;
    
    public $customer;//input constructor param

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            // name, email, subject and body are required
            [['subscribe', 'token', 'idCustomer' ], 'safe'],
        	[['subscribe' ], 'required'   ],
        	[['subscribe' ], 'validateSubscribe'  ,'skipOnEmpty' => false, 'skipOnError' => false ],
           
        ];
    }

    public function validateSubscribe($attr,$param){
    	if ( $this->subscribe != '1'){
    		echo "subscribe failed";
    		$this->addError( "subscribe", "Feliratkozáshoz be kell jelölnie ezt a mezőt!");
    	}
    }
    
    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'subscribe' => 'Szeretnék hírlevelet kapni',
        ];
    }

    
    
    
}
