123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- <?php
- /**
- * KataoNode form base class.
- *
- * @package form
- * @subpackage katao_node
- * @version SVN: $Id: sfPropelFormGeneratedTemplate.php 15484 2009-02-13 13:13:51Z fabien $
- */
- class BaseKataoNodeForm extends BaseFormPropel
- {
- public function setup()
- {
- $this->setWidgets(array(
- 'id' => new sfWidgetFormInputHidden(),
- 'city' => new sfWidgetFormInput(),
- 'responsible' => new sfWidgetFormPropelSelect(array('model' => 'KataoUser', 'add_empty' => true)),
- 'begin_at' => new sfWidgetFormDateTime(),
- 'is_default' => new sfWidgetFormInput(),
- 'created_at' => new sfWidgetFormDateTime(),
- 'updated_at' => new sfWidgetFormDateTime(),
- 'katao_supplier_node_list' => new sfWidgetFormPropelSelectMany(array('model' => 'KataoSupplier')),
- ));
- $this->setValidators(array(
- 'id' => new sfValidatorPropelChoice(array('model' => 'KataoNode', 'column' => 'id', 'required' => false)),
- 'city' => new sfValidatorString(array('max_length' => 255)),
- 'responsible' => new sfValidatorPropelChoice(array('model' => 'KataoUser', 'column' => 'id', 'required' => false)),
- 'begin_at' => new sfValidatorDateTime(),
- 'is_default' => new sfValidatorInteger(array('required' => false)),
- 'created_at' => new sfValidatorDateTime(array('required' => false)),
- 'updated_at' => new sfValidatorDateTime(array('required' => false)),
- 'katao_supplier_node_list' => new sfValidatorPropelChoiceMany(array('model' => 'KataoSupplier', 'required' => false)),
- ));
- $this->widgetSchema->setNameFormat('katao_node[%s]');
- $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
- parent::setup();
- }
- public function getModelName()
- {
- return 'KataoNode';
- }
- public function updateDefaultsFromObject()
- {
- parent::updateDefaultsFromObject();
- if (isset($this->widgetSchema['katao_supplier_node_list']))
- {
- $values = array();
- foreach ($this->object->getKataoSupplierNodes() as $obj)
- {
- $values[] = $obj->getKataoSupplierId();
- }
- $this->setDefault('katao_supplier_node_list', $values);
- }
- }
- protected function doSave($con = null)
- {
- parent::doSave($con);
- $this->saveKataoSupplierNodeList($con);
- }
- public function saveKataoSupplierNodeList($con = null)
- {
- if (!$this->isValid())
- {
- throw $this->getErrorSchema();
- }
- if (!isset($this->widgetSchema['katao_supplier_node_list']))
- {
- // somebody has unset this widget
- return;
- }
- if (is_null($con))
- {
- $con = $this->getConnection();
- }
- $c = new Criteria();
- $c->add(KataoSupplierNodePeer::KATAO_NODE_ID, $this->object->getPrimaryKey());
- KataoSupplierNodePeer::doDelete($c, $con);
- $values = $this->getValue('katao_supplier_node_list');
- if (is_array($values))
- {
- foreach ($values as $value)
- {
- $obj = new KataoSupplierNode();
- $obj->setKataoNodeId($this->object->getPrimaryKey());
- $obj->setKataoSupplierId($value);
- $obj->save();
- }
- }
- }
- }
|