| 1 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/**
|
|
|
4 |
* Category form base class.
|
|
|
5 |
*
|
|
|
6 |
* @method Category getObject() Returns the current form's model object
|
|
|
7 |
*
|
|
|
8 |
* @package ##PROJECT_NAME##
|
|
|
9 |
* @subpackage form
|
|
|
10 |
* @author Your name here
|
|
|
11 |
*/
|
|
|
12 |
abstract class BaseCategoryForm extends BaseFormPropel
|
|
|
13 |
{
|
|
|
14 |
public function setup()
|
|
|
15 |
{
|
|
|
16 |
$this->setWidgets(array(
|
|
|
17 |
'id' => new sfWidgetFormInputHidden(),
|
|
|
18 |
'name' => new sfWidgetFormInputText(),
|
|
|
19 |
));
|
|
|
20 |
|
|
|
21 |
$this->setValidators(array(
|
|
|
22 |
'id' => new sfValidatorChoice(array('choices' => array($this->getObject()->getId()), 'empty_value' => $this->getObject()->getId(), 'required' => false)),
|
|
|
23 |
'name' => new sfValidatorString(array('max_length' => 255, 'required' => false)),
|
|
|
24 |
));
|
|
|
25 |
|
|
|
26 |
$this->validatorSchema->setPostValidator(
|
|
|
27 |
new sfValidatorPropelUnique(array('model' => 'Category', 'column' => array('name')))
|
|
|
28 |
);
|
|
|
29 |
|
|
|
30 |
$this->widgetSchema->setNameFormat('category[%s]');
|
|
|
31 |
|
|
|
32 |
$this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
|
|
|
33 |
|
|
|
34 |
parent::setup();
|
|
|
35 |
}
|
|
|
36 |
|
|
|
37 |
public function getModelName()
|
|
|
38 |
{
|
|
|
39 |
return 'Category';
|
|
|
40 |
}
|
|
|
41 |
|
|
|
42 |
|
|
|
43 |
}
|