<?php

/**
 * KataoNode form.
 *
 * @package katao
 * @subpackage form
 * @author Your name here
 * @version SVN: $Id: sfPropelFormTemplate.php 10377 2008-07-21 07:10:32Z dwhittle $
 */
class KataoNodeForm extends BaseKataoNodeForm {
    public function configure() {
        unset($this->validatorSchema['is_default'], $this->validatorSchema['katao_supplier_node_list'], $this->validatorSchema['created_at'], $this->validatorSchema['updated_at']);
        unset($this->widgetSchema['is_default'], $this->widgetSchema['katao_supplier_node_list'], $this->widgetSchema['created_at'], $this->widgetSchema['updated_at']);

        $this->widgetSchema['responsible'] = new sfWidgetFormSelect(array('choices' => KataoUserPeer::getMembersByNodeToArray($this->getObject()->getId())));
        if ($this->getObject()->isNew()) {
            $this->setDefault('responsible', sfContext::getInstance()->getUser()->getInstance()->getId());
        }

        $this->widgetSchema['begin_at'] = new wpWidgetFormRichDate();
        $this->validatorSchema['begin_at'] = new sfValidatorDateTime(array('date_format' => '@(?P<day>\d{2}).(?P<month>\d{2}).(?P<year>\d{4})@'));
        $this->setDefault('begin_at', time());

        $this->widgetSchema->setLabels(array(
                'city' => 'Ville',
                'responsible' => 'Délégué',
                'begin_at' => 'Date de création',
                ));
    }
}