Example #1
0
 /**
  * Finds the ItemProp model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return ItemProp the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     $itemPropClass = Kiwi::getItemPropClass();
     if (($model = $itemPropClass::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #2
0
 /**
  * @param \yii\bootstrap\ActiveForm $form
  * @return string
  */
 public function formFields($form)
 {
     $itemPropClass = Kiwi::getItemPropClass();
     $html = '';
     foreach ($this->itemProps as $key => $itemProp) {
         $options = $itemProp->toArray();
         foreach ($options as $field => $value) {
             $options['data-' . str_replace('_', '-', $field)] = $value;
             unset($options[$field]);
         }
         /** @var \yii\bootstrap\ActiveField $field */
         $field = $form->field($this, $key, ['options' => $options, 'inputOptions' => $options]);
         if (in_array($itemProp->type, [$itemPropClass::ITEM_PROP_TYPE_SELECT, $itemPropClass::ITEM_PROP_TYPE_CHECKBOX])) {
             $items = [];
             foreach ($itemProp->propValues as $propValue) {
                 $items[$propValue->prop_value_id] = $propValue->name;
             }
             $itemOptions = array_merge($options, ['container' => false, 'labelOptions' => ['class' => 'radio-inline']]);
             $field = $itemProp->type == $itemPropClass::ITEM_PROP_TYPE_SELECT ? $field->inline()->radioList($items, ['itemOptions' => $itemOptions]) : $field->inline()->checkboxList($items, ['itemOptions' => $itemOptions]);
         }
         $html .= $field->render();
     }
     return $html;
 }
Example #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getItemProp()
 {
     return $this->hasOne(Kiwi::getItemPropClass(), ['item_prop_id' => 'item_prop_id']);
 }