<?php echo Form::select('department_id', '', $department, array('class' =--> 'span4')); ?
$this->template->set_global('department', Model_User::get_department(), false);
$this->template->title = "Users";
$this->template->content = View::forge('admin\user/create');
public static function get_department()
{
$query = DB::select('id', 'department')->from('departments')->execute();
$result = $query->as_array('id', 'department');
return $result;
}
<?php echo Form::select('department_id', '', $department, array('value' => $selected, 'class' => 'span4')); ?Or do you mean adding a placeholder?
<?php echo Form::select('department_id', '', $department, array('value' => $department_id, 'class' => 'span4')); ?
public function action_edit($id = null)
{
$user = Model_User::find($id);
!($user and $id) and Response::redirect('admin/user');
$val = Model_User::validate('edit');
if ($val->run())
{
$user->username = Input::post('username');
$user->name = Input::post('name');
$user->email = Input::post('email');
$user->mobile = Input::post('mobile');
$user->birthday = Input::post('birthday');
$user->department_id = Input::post('department_id');
$user->rank_id = Input::post('rank_id');
$user->updated_at = CEDate::now();
if ($user->save())
{
Response::redirect('admin/user');
}
else
{
$this->template->set_global('msg', $val->show_errors(),FALSE);
}
}
else
{
if (Input::method() == 'POST')
{
$user->username = $val->validated('username');
$user->name = $val->validated('name');
$user->email = $val->validated('email');
$user->mobile = $val->validated('mobile');
$user->birthday = $val->validated('birthday');
$user->department_id = $val->validated('department_id');
$user->rank_id = $val->validated('rank_id');
$this->template->set_global('msg', $val->show_errors(),FALSE);
}
$this->template->set_global('user', $user, false);
}
$this->template->set_global('rank', Model_Rank::get_rank(), false);
$this->template->set_global('department', Model_Department::get_department(), false);
$this->template->title = "Users";
$this->template->content = View::forge('admin\user/edit');
}
<?php echo Form::label('Department', 'department_id'); ?>
<?php echo Form::select('department_id', '', $department, array('value' => $user->department_id, 'class' => 'span4')); ?>
<?php echo Form::select('department_id', $user->department_id, $department, array('class' => 'span4')); ?>
It looks like you're new here. If you want to get involved, click one of these buttons!