本文整理汇总了PHP中FormField::model方法的典型用法代码示例。如果您正苦于以下问题:PHP FormField::model方法的具体用法?PHP FormField::model怎么用?PHP FormField::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FormField
的用法示例。
在下文中一共展示了FormField::model方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionDelete
/**
* 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()
{
if (isset($_GET['form'])) {
$form_id = $_GET['form'];
$model = Form::model()->findByPk($form_id);
$table_name = $model->TABLE_NAME;
$this->loadModel($form_id)->delete();
if (Yii::app()->db->schema->getTable($table_name)) {
Yii::app()->db->createCommand()->dropTable($table_name);
FormField::model()->deleteAllByAttributes(array('FORM_ID' => $form_id));
}
} else {
throw new CHttpException(404, 'The requested page does not exist.');
}
// 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('all'));
}
}
示例2: getFields
public static function getFields()
{
$form_id = Yii::app()->params['form-id'];
self::$_model = FormField::model()->findAllByAttributes(array('FORM_ID' => $form_id), array('order' => 'POSITION ASC'));
return self::$_model;
}
示例3: actionView
public function actionView()
{
if (isset($_GET['form'])) {
$table_id = $_GET['form'];
if (isset($_GET['entry'])) {
$entry_id = $_GET['entry'];
$fields = FormField::model()->findAllByAttributes(array('FORM_ID' => $table_id), array('order' => 'POSITION ASC'));
} else {
$entry_id = NULL;
}
} else {
throw new CHttpException(404, 'The requested page does not exist.');
}
$this->render('view', array('model' => $this->loadModel($table_id, $entry_id), 'table_id' => $table_id, 'entry_id' => $entry_id, 'fields' => $fields, 'form' => Form::model()->findByPk($table_id)));
}
示例4: loadModel
/**
* 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 FormField the loaded model
* @throws CHttpException
*/
public function loadModel($id)
{
$model = FormField::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}