//controller
public function actionCreate(){
$model=new EmployeeSchedule;
$employee = Employee::model()->findAll();
if(isset($_POST['EmployeeSchedule']))
{
echo $_POST['emp_sel'];
$model->attributes=$_POST['EmployeeSchedule'];
if($model->save())
$this->redirect(array('view','id'=>$model->id));
}
$this->render('create',array(
'employee'=>$employee,
'model'=>$model,));
}
//view
$this->widget(
'bootstrap.widgets.TbSelect2',
array(
'asDropDownList' => false,
'name' => 'emp_sel',
'options' => array(
'tags' => $employee['firsname'],
'placeholder' => 'Type the name of employee and press enter to select',
'width' => '100%',
'tokenSeparators' => array(',', ' ')
)
)
);
?>
//Error
PHP notice
Undefined index: firstname
Please Help.
I want to view the firstname field and save the Id…
Thanks for help