<?php
/**
 * class auth_reset_form
 *
 * Description for class auth_reset_form
 *
 * @author:
*/
namespace form;

use core\form;

class auth_reset_form extends form {
	public $password = "";
	public $repassword = "";

	public function init() {
		$this->addElement("password", array("required"));
		$this->addElement("repassword", array("required"));
	}

	public function valid() {
		if(!$this->send) {
			return false;
		}

		$valid = true;

		$this->password = $this->getElement("password")->getValue();
		if(empty($this->password)) {
			$this->elements["password"]->setError("Pole wymagane");
			$valid = false;
		}

		$this->repassword = $this->getElement("repassword")->getValue();
		if(empty($this->repassword)) {
			$this->elements["repassword"]->setError("Pole wymagane");
			$valid = false;
		} elseif($this->password != $this->repassword) {
			$this->elements["repassword"]->setError("Powtórz poprawnie hasło");
			$valid = false;
		}
		
		return $valid;
	}
}
?>