ArticleForm.class.php 2.12 KB
Newer Older
Яков's avatar
first  
Яков committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?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' => 'Обязательное поле'));
    }
}