Skip to content

Instantly share code, notes, and snippets.

@cedricziel
Created December 8, 2010 11:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cedricziel/733152 to your computer and use it in GitHub Desktop.
Save cedricziel/733152 to your computer and use it in GitHub Desktop.
Das Formular
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());
}
<?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