<?php

require_once '../../../Wact/Loader.inc.php';
Wact_Loader::setupWact();

/**
*/
class WactFormExampleView extends Wact_View_Root {
    /**
    */
    function setup() {
        $this->onPreRenderDo($this, 'init');
    }
    
    /**
    */
    function init() {
        $state = $this->getChild('state');
        $state->setChoices(array('a' => 'State A', 'b' => 'State B'));

        $interests = $this->getChild('interests');
        $interests->setChoices(array('a' => 'Interest A', 'b' => 'Interest B', 'c' => 'Interest C'));
    }
}

/**
*/
class WactFormExample extends Wact_Controller_Base {
    /**
    */
    function setup() {
        $this->defineInput(new Wact_Request_Post('name'))->bindToModel();
        $this->defineInput(new Wact_Request_Post('passwd'))->bindToModel();
        $this->defineInput(new Wact_Request_Post('sex'))->bindToModel();
        $this->defineInput(new Wact_Request_Post('newsletter'))->bindToModel();
        $this->defineInput(new Wact_Request_Post('state'))->bindToModel();
        $this->defineInput(new Wact_Request_Post('interests'))->bindToModel();
        $this->defineInput(new Wact_Request_Post('introduction'))->bindToModel();
        
        // a similar signature for setView() is required? (without the first parameter)
        $this->setPartialView('(dummy)', 'forms.tpl.html', 'WactFormExampleView');
    }
}

$config = new Wact_Config_Registry();
$config->WactFormExample->start();

?>