Created
December 8, 2010 11:09
-
-
Save cedricziel/733152 to your computer and use it in GitHub Desktop.
Das Formular
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function executeShow(sfWebRequest $request) { | |
$this->wachbericht_bericht = Doctrine::getTable('WachberichtBericht')->find($request->getParameter('id')); | |
//$this->setVar('berichtID', $this->wachbericht_bericht->getId()); | |
$this->forward404Unless($this->wachbericht_bericht); | |
$this->formQuickentry = new WachberichtWachstundenQuickentryForm; | |
$this->formQuickentry->setBerichtId($this->wachbericht_bericht->getId()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class WachberichtWachstundenQuickentryForm extends BaseFormDoctrine { | |
public function setup() { | |
$this->setWidgets(array( | |
'id' => new sfWidgetFormInputHidden(), | |
'person_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('WachberichtPerson'), 'add_empty' => false)), | |
'bericht_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('WachberichtBericht'), 'add_empty' => false)), | |
'anfang' => new sfWidgetFormTime(), | |
'ende' => new sfWidgetFormTime(), | |
'created_at' => new sfWidgetFormDateTime(), | |
'updated_at' => new sfWidgetFormDateTime(), | |
)); | |
$this->setValidators(array( | |
'id' => new sfValidatorDoctrineChoice(array('model' => $this->getModelName(), 'column' => 'id', 'required' => false)), | |
'person_id' => new sfValidatorDoctrineChoice( | |
array( | |
'model' => $this->getRelatedModelName('WachberichtPerson') | |
) | |
), | |
'bericht_id' => new sfValidatorDoctrineChoice( | |
array( | |
'model' => $this->getRelatedModelName('WachberichtBericht') | |
) | |
), | |
'anfang' => new sfValidatorTime(array(), array('required' => 'benötigt')), | |
'ende' => new sfValidatorTime(), | |
'created_at' => new sfValidatorDateTime(), | |
'updated_at' => new sfValidatorDateTime(), | |
)); | |
$this->validatorSchema->setPostValidator( | |
new sfValidatorSchemaCompare('anfang', '<', 'ende'), | |
new sfValidatorDoctrineUnique( | |
array( | |
'model' => 'WachberichtWachstunden', | |
'column' => array( | |
'bericht_id', | |
'person_id' | |
) | |
) | |
) | |
); | |
$this->widgetSchema->setNameFormat('wachbericht_wachstunden[%s]'); | |
$this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema); | |
$this->setupInheritance(); | |
parent::setup(); | |
} | |
public function getModelName() { | |
return 'WachberichtWachstunden'; | |
} | |
public function configure() { | |
$this->setWidget('anfang', new sfWidgetFormTime(array('minutes' => array('00', 15, 30, 45)))); | |
$this->setWidget('ende', new sfWidgetFormTime(array('minutes' => array('00', 15, 30, 45)))); | |
unset( | |
$this['created_at'], $this['updated_at'], | |
$this['expires_at'], $this['is_activated'] | |
); | |
} | |
public function setBerichtId($id = null) { | |
$this->setWidget('bericht_id', new sfWidgetFormInputHidden(array(), array('value' => $id))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment