setElementDefaultOptions() 보호된 메소드

Looks for a methods based on the class name of the element: setElementDefaultOptions_[element class name] This method is passed the element and action, which allows for controller methods to manipulate the default values of the element (if the controller state is required for this)
protected setElementDefaultOptions ( BaseEventTypeElement $element, string $action )
$element BaseEventTypeElement
$action string
예제 #1
0
 /**
  * Set prescription item defaults when creating.
  *
  * @param BaseEventTypeElement $element
  * @param string               $action
  */
 protected function setElementDefaultOptions($element, $action)
 {
     parent::setElementDefaultOptions($element, $action);
     if ($action == 'create' && get_class($element) == 'Element_OphDrPrescription_Details') {
         // Prepopulate prescription with set by episode status
         // FIXME: It's brittle relying on the set name matching the status
         $items = array();
         $status_name = $this->episode->status->name;
         $subspecialty_id = $this->firm->getSubspecialtyID();
         $params = array(':subspecialty_id' => $subspecialty_id, ':status_name' => $status_name);
         $set = DrugSet::model()->find(array('condition' => 'subspecialty_id = :subspecialty_id AND name = :status_name', 'params' => $params));
         if ($set) {
             foreach ($set->items as $item) {
                 $item_model = new OphDrPrescription_Item();
                 $item_model->drug_id = $item->drug_id;
                 $item_model->loadDefaults();
                 $items[] = $item_model;
             }
         }
         $element->items = $items;
     }
 }
예제 #2
0
 /**
  * extends the base function to set various defaults that depend on other events etc.
  *
  * @param BaseElement $element
  * @param string      $action
  */
 public function setElementDefaultOptions($element, $action)
 {
     parent::setElementDefaultOptions($element, $action);
     if ($action == 'create' && empty($_POST)) {
         switch (get_class($element)) {
             case 'Element_OphCoTherapyapplication_Therapydiagnosis':
                 $this->setDiagnosisDefaults($element);
                 break;
             case 'Element_OphCoTherapyapplication_MrServiceInformation':
                 $element->consultant_id = Yii::app()->session['selected_firm_id'];
                 $element->site_id = Yii::app()->session['selected_site_id'];
                 break;
         }
     }
 }