本文整理汇总了PHP中Actions::getFormTypes方法的典型用法代码示例。如果您正苦于以下问题:PHP Actions::getFormTypes方法的具体用法?PHP Actions::getFormTypes怎么用?PHP Actions::getFormTypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Actions
的用法示例。
在下文中一共展示了Actions::getFormTypes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
if (Yii::app()->user->isGuest && !Yii::app()->user->checkAccess($_POST['Actions']['associationType'] . 'View')) {
$this->denied();
}
$formTypes = Actions::getFormTypes();
foreach ($formTypes as $type) {
// determine which kind of action we're creating
if (isset($_POST[$type])) {
$post = $_POST[$type];
$modelType = $type;
break;
}
}
if (!isset($modelType) && isset($_POST['actionType']) && in_array($_POST['actionType'], $formTypes)) {
$modelType = $_POST['actionType'];
} elseif (!isset($modelType)) {
$modelType = 'Actions';
}
$model = new $modelType();
if (isset($post)) {
if ($model instanceof ActionFormModelBase) {
$model->setAttributes($post);
if ($model->validate()) {
$model = $model->getAction();
// convert to active record
}
} else {
// ($model instanceof Actions)
$model->setX2Fields($post);
}
if (!$model->hasErrors() && isset($_POST['x2ajax'])) {
$this->quickCreate($model);
$model->syncGoogleCalendar('create');
} elseif (!$model->hasErrors() && $model->save()) {
$model->syncGoogleCalendar('create');
$this->redirect(array('index'));
}
}
if (empty($model->assignedTo)) {
$model->assignedTo = Yii::app()->user->getName();
}
if (isset($_POST['x2ajax'])) {
// allows form to be refreshed
if (!$model->hasErrors()) {
$model = new $modelType();
}
$this->renderInlineForm($model);
} else {
$this->render('create', array('model' => $model));
}
}