Support the ongoing development of Laravel.io →
Input Views Validation
Last updated 1 year ago.
0
return Redirect::action('UserController@editUser')->withErrors($validator->errors()); // THIS BUGGED

Does this need you to pass the ID parameter like so:

return Redirect::action('UserController@editUser' , array('id'=>Auth::id()) )->withErrors($validator->errors());
Last updated 1 year ago.
0

Thanks, i will try it out. But can i pass not my current ID, but the id of user which i am looking for. In my case it's 1. With Auth::id() i am getting my current id.

Last updated 1 year ago.
0

Ahh of course yes, pass the id of the post owner :)

Last updated 1 year ago.
0

Thanks, but why do i have to do that? I have other method in same controller, but it works without sending any variables:

	public function editMyProfile() {
		$user = $this->user->find(Auth::id());
		return View::make('auth.editUser')->with('user', $user);
	}

	public function doEditMyProfile() {
		// Validation
		$validator = new UserEditFormValidator(Input::all());

		if ($validator->fails()) {
			return Redirect::action('UserController@editMyProfile')->withErrors($validator->errors());
		}

		$input = array(
			'id' => Input::get('id'),
			'name' => Input::get('name'),
			'active' => (Input::has('active')) ? true : false,
			'password' => Input::get('password')
		); 

		$this->user->update($input);
		return Redirect::action('UserController@editMyProfile')->with('success', 'Your profile data has been updated');
	}
Last updated 1 year ago.
0

I have noticed, when i submit form via POST it redirect me to url:

users/{id}/edit

instead of:

users/1/edit

So i need to send variable with Redirect class only in case of using get variables?

Last updated 1 year ago.
0

I beleive its because your method editUser requires the parameter $id

public function editUser($id) {
    $user = $this->user->find($id);
    return View::make('auth.editUser')->with('user', $user);
}

Where as editMyProfile doesn't

public function editMyProfile() {
    $user = $this->user->find(Auth::id());
    return View::make('auth.editUser')->with('user', $user);
}

At least that'd be my assumptions

Hope that helps

Last updated 1 year ago.
0

heihachi88 said:

Thanks, i will try it out. But can i pass not my current ID, but the id of user which i am looking for. In my case it's 1. With Auth::id() i am getting my current id.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.