<?php

/**
 * Description of Volunteer
 *
 * @author ain
 */
class Volunteer extends CFormModel {

	public $gender;
	public $age;
	public $useten;
	public $fingeruse;

	public function rules() {
		return array(
			array('gender', 'required'),
			array('gender', 'in', 'range' => array('M', 'F')),
			array('age', 'numerical', 'integerOnly' => true, 'min' => 12, 'max' => 99, 'allowEmpty' => false),
			array('useten', 'in', 'range' => array('0', '1'), 'allowEmpty' => false),
			array('fingeruse', 'numerical', 'integerOnly' => true, 'min' => 1, 'max' => 10, 'allowEmpty' => false)
		);
	}

	public function attributeLabels() {
		return array(
			'gender' => 'Sugu',
			'age' => 'Vanus',
			'useten' => 'Vastus',
			'fingeruse' => 'Vastus',
		);
	}

	public function getForm() {
		$fingerUseItems = array('10' => '');
		for($i = 1; $i < 10; $i++) {
			$fingerUseItems["$i"] = $i;
		}

		return new CForm(array(
			'showErrorSummary' => true,
			'attributes' => array('id' => 'keyWizard'),
			'elements' => array(
				'gender' => array(
					'type' => 'radiolist',
					'items' => array('M' => 'Mees', 'F' => 'Naine'),
				),
				'age' => array(
					'type' => 'dropdownlist',
					'empty' => '',
					'items' => array_combine(range(12, 99), range(12, 99)),

				),
				"<span>Kas kasutad klaviatuuril trükkimisel kõiki kümmet sõrme?\n</span>",
				'useten'=>array(
					'type' => 'radiolist',
					'items' => array('1' => 'Jah', '0' => 'Ei'),
				),
				'<span>Kui mitut sõrme kasutad (sh pöial)?</span>',
				'fingeruse' => array(
					'type' => 'dropdownlist',
					'items' => $fingerUseItems
				),
			),
			'buttons' => array(
				'submit' => array(
					'type' => 'submit',
					'label' => 'Edasi'
				)
			)

		), $this);
	}
}
