public function attach($owner) { parent::attach($owner); if (!isset($this->baseRoute)) { $this->baseRoute = '/' . strtolower(get_class($this->owner)); } // assume the model name is the same as the controller if (!isset($this->viewRoute)) { $this->viewRoute = $this->baseRoute; } if (!isset($this->autoCompleteSource)) { $this->autoCompleteSource = $this->baseRoute . '/getItems'; } // assume the model name is the same as the controller }
public function beforeValidate($event) { parent::beforeValidate($event); $valid = true; foreach ($this->getDateTimes() as $dateTimeForm) { $valid = $dateTimeForm->validate() && $valid; if (!$dateTimeForm->hasErrors()) { $this->owner->{$dateTimeForm->dateTimeAttribute} = $dateTimeForm->getTimestamp(); } else { foreach ($dateTimeForm->getErrors() as $attribute => $errors) { $event->sender->addErrors(array($dateTimeForm->dateTimeAttribute => $errors)); } } } $event->isValid = $valid; }
/** * Declares events and the corresponding event handler methods. * If you override this method, make sure you merge the parent result to the return value. * @return array events (array keys) and the corresponding event handler methods (array values). * @see CBehavior::events */ public function events() { return array_merge(parent::events(), array('onBeforeSave' => 'beforeSave', 'onAfterSave' => 'afterSave', 'onBeforeDelete' => 'beforeDelete', 'onAfterDelete' => 'afterDelete', 'onBeforeFind' => 'beforeFind', 'onAfterFind' => 'afterFind', 'onBeforeCount' => 'beforeCount')); }
/** * Declares events and the corresponding event handler methods. * * @return array events (array keys) and the corresponding event handler methods (array values). * * @see CBehavior::events */ public function events() { $base = parent::events(); $additional = array('onBeforeSubmit' => 'beforeSubmit', 'onAfterSubmit' => 'afterSubmit'); return array_merge($base, $additional); }
/** * @see UploadingBehavior. */ public function attach($owner) { parent::attach($owner); $this->_component->attach(); }