Answer the question
In order to leave comments, you need to log in
Yii creating an element in a module?
I do an admin panel in the module. created a model\crud.
when saving, it cannot pass the record id to the view. and the layout of the main site still puts. although the path is normal
../admin/page/id
it seems that he does not know his $model->id
Answer the question
In order to leave comments, you need to log in
did it but it's not right
public function actionCreate()
{
$model = new Role;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Role']))
{
$model->attributes = $_POST['Role'];
if ($model->save())
{
if (isset($_POST['im_id']))
{
$command = Yii::app()->db->createCommand();
$maxOrderNumber = Yii::app()->db->createCommand()
->select('max(id) as max')
->from('t_role')
->queryScalar();
$max = $maxOrderNumber ;
foreach ($_POST['im_id'] as $check)
{
$Ids = $_POST['im_id'];
};
for ($i = 0; $i < count($Ids); $i++)
{
$command->insert('t_haspage', array(
'id_role' => $max, ////
'id_page' => (int) $Ids[$i], ////
));
}
}
$this->redirect(array('view', 'id' => $max));
}
}
$this->render('create', array(
'model' => $model,
));
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question