<?php

/**
 * Article form.
 *
 * @package    sf
 * @subpackage form
 * @author     Atma
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class ArticleForm extends BaseArticleForm
{
    public function configure()
    {
        $this->embedI18n(array('ru', 'en'));
        $this->useFields(array('alias', 'ru', 'en', 'cover', 'tags_list'));

        $this->widgetSchema['alias'] = new sfWidgetFormInputText(array(), array("class" => "translateField", "size" => 32, "maxlength" => 255));
        $this->validatorSchema['alias'] = new sfValidatorString(array('max_length' => 500, 'only_english' => true, 'required' => false));

        $this->widgetSchema['tags_list'] = new sfWidgetFormDoctrineChoice(array('multiple' => true, 'model' => 'Tag', 'expanded' => true));

        $this->widgetSchema['cover'] = new sfWidgetFormInputFileUpload(array(
            'allowedFileTypes' => 'image/png,image/jpeg',
            'script' => '/uploader?key=article'
        ), array('required' => true));

        $this->widgetSchema['ru']['title'] = new sfWidgetFormInputText(array("label" => "Название"), array("size" => 64, "maxlength" => 255));
        $this->widgetSchema['en']['title'] = new sfWidgetFormInputText(array("label" => "Название"), array("size" => 64, "maxlength" => 255));
        $this->widgetSchema['ru']['description'] = new sfWidgetFormTextarea(array("label" => "Описание"), array("rows" => 5, "cols" => 70, "maxlength" => 240));
        $this->widgetSchema['en']['description'] = new sfWidgetFormTextarea(array("label" => "Описание"), array("rows" => 5, "cols" => 70, "maxlength" => 240));
        $this->widgetSchema['ru']['body'] = new sfWidgetFormTextarea(array("label" => "Текст"), array("class" => "rich", "rows" => 5, "cols" => 70));
        $this->widgetSchema['en']['body'] = new sfWidgetFormTextarea(array("label" => "Текст"), array("class" => "rich", "rows" => 5, "cols" => 70));

        $this->validatorSchema['ru']['available'] = new sfValidatorChoice(array('choices' => array(true)), array('invalid' => 'Обязательное поле'));
    }
}
