<?php
/**
 * class presentation_create_form
 *
 * Description for class presentation_create_form
 *
 * @author:
*/
namespace area\presenter\form;

use core\form;

class presentation_create_form extends form {
	public $name = "";
	public $tempo = "";

	public function init() {
		$this->addElement("name", array("required", "max_length(80)"));
		$this->addElement("tempo", array("required"), array("1", "2"));
	}

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

		$valid = true;

		$this->name = $this->getElement("name")->getValue();
		if(empty($this->name)) {
			$this->elements["name"]->setError("Pole wymagane");
			$valid = false;
		} elseif(strlen($this->name) > 80) {
			$this->elements["name"]->setError("Maksymalna długość 80 znaków");
			$valid = false;
		}

		$this->tempo = $this->getElement("tempo")->getValue();
		if(empty($this->tempo) || !$this->getElement("tempo")->optionExist()) {
			$this->elements["tempo"]->setError("Pole wymagane");
			$valid = false;
		}
		
		return $valid;
	}
}
?>