本文整理汇总了PHP中Options::hasErrors方法的典型用法代码示例。如果您正苦于以下问题:PHP Options::hasErrors方法的具体用法?PHP Options::hasErrors怎么用?PHP Options::hasErrors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Options
的用法示例。
在下文中一共展示了Options::hasErrors方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionAddOption
/**
* actionAddOption
*
* @access public
* @return void
*/
public function actionAddOption($id)
{
Yii::log("actionIndex OptionsController called", "trace", self::LOG_CAT);
$model = new Options();
$model->setCustomScenario($id);
if (isset($_POST['Options'])) {
$model->attributes = $_POST['Options'];
//print_r($model); die;
if ($model->save()) {
Yii::app()->user->setFlash('success', "Option successfully added.");
$this->redirect(['options/index/id/' . $id]);
}
if (!$model->hasErrors()) {
Yii::app()->user->setFlash('error', "An error occurred while adding the option, please contact your administrator.");
}
}
// add options via ajax from chosen plugin
// if(isset($_POST['options'])) {
// $model->setScenario($_POST['options']['scenario']);
// unset($_POST['options']['scenario']);
// $model->attributes = $_POST['options'];
// if($model->save()) {
// echo json_encode(ModelToArray::convertModelToArray($model, [$model->tableName() => 'optionId, label']));
// return;
// }
// $model->unsetAttributes();
// //print_r($model->attributeNames()); die;
// echo json_encode(['optionId' => '']);
// return;
//
// }
// echo get_class($this->optionsMask['formFieldsModels'][$id]);
// Select all values whose inputType is ""Select"
$formElementsCriteria = new CDbCriteria();
$formElementsCriteria->condition = "t.inputType='dropdownlist'";
if ($this->optionsMask['formFieldsModels'][$id] == 'FrameworkFields') {
// $formElementsCriteria->join = 'LEFT JOIN parentLabel AS frameworkFields ON parentLabel.id = t.parentId';
$formElementsCriteria->with = 'parent';
}
//$formElementsModel = new {$this->optionsMask['formFieldsModels'][$id]};
$fetchOptions = CActiveRecord::model($this->optionsMask['formFieldsModels'][$id])->findAll($formElementsCriteria);
//print_r($fetchOptions); die;
$formElements = CHtml::listData($fetchOptions, $this->optionsMask['joinLabels'][$id][0], function ($option) use($id) {
if (isset($option->parent)) {
return $option->parent->label . ' - ' . $option->{$this->optionsMask['joinLabels'][$id][1]};
}
return $option->{$this->optionsMask['joinLabels'][$id][1]};
});
//print_r($formElements); die;
$this->render('add', ['model' => $model, 'dropDownAttribute' => $this->optionsMask['relationNames'][$id] . 'Id', 'formElements' => $formElements]);
}