/**
  * Manages all models.
  */
 public function actionAdmin($type)
 {
     $field = FieldNames::model()->findByAttributes(array('name' => $type));
     $model = new FieldValues('search');
     $model->unsetAttributes();
     // clear any default values
     $model->field_id = $field->id;
     if (isset($_GET['FieldValues'])) {
         $model->attributes = $_GET['FieldValues'];
     }
     $this->render('admin', array('model' => $model));
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return FieldNames the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = FieldNames::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
예제 #3
0
<div class="form">

<?php 
$form = $this->beginWidget('CActiveForm', array('id' => 'field-values-form', 'enableAjaxValidation' => false));
?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php 
echo $form->errorSummary($model);
?>

	<?php 
if ($_GET['type']) {
    $field = FieldNames::model()->findByAttributes(array('name' => $_GET['type']));
    echo $form->hiddenField($model, 'field_id', array('value' => $field->id));
} else {
    echo '<div class="row">';
    echo $form->labelEx($model, 'field_id');
    echo $form->textField($model, 'field_id');
    echo $form->error($model, 'field_id');
    echo "</div>";
}
?>

	<div class="row">
		<?php 
echo $form->labelEx($model, 'name');
?>
		<?php