if ($customFields) { foreach ($customFields as $field) { ?> <div class="control-group"> <div class="control-label"> <?php echo $form->labelEx($model, $field->varname); ?> </div> <div class="controls"> <?php if ($widgetEdit = $field->widgetEdit($model)) { echo $widgetEdit; } elseif ($field->range) { echo $form->dropDownList($model, $field->varname, BaseCccdCompanyData::range($field->range)); } elseif ($field->field_type == "BOOL") { echo $form->checkBox($model, $field->varname); } elseif ($field->field_type == "TEXT") { echo CHtml::activeTextArea($model, $field->varname, array('rows' => 6, 'cols' => 50)); } elseif ($field->field_type == "ListBox") { $list_data = json_decode($field->widgetparams, true); echo $form->listBox($model, $field->varname, $list_data); } else { echo $form->textField($model, $field->varname, array('size' => 60, 'maxlength' => $field->field_size ? $field->field_size : 255)); } echo $form->error($model, $field->varname); ?> </div> </div> <?php
public static function getFields() { self::$_model = BaseCccfCustomField::model()->findAll(); return self::$_model; }
/** * Deletes a particular model. * If deletion is successful, the browser will be redirected to the 'admin' page. * @param integer $id the ID of the model to be deleted */ public function actionDelete($id) { //$this->loadModel($id)->delete(); // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser //if(!isset($_GET['ajax'])) // $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin')); $model = $this->loadModel($id); $sql = 'ALTER TABLE ' . BaseCccdCompanyData::model()->tableName() . ' DROP `' . $model->varname . '`'; if ($model->dbConnection->createCommand($sql)->execute()) { $model->delete(); } // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser if (!isset($_POST['ajax'])) { $this->redirect(array('admin')); } else { throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.'); } }