0

I'm using {!! Form::model( $data) !!} to get my edit working dynamically, also I have normal inputs like {!! Form::text('name', null) !!} but, within my controller, before I send my $data to my view, I use with like the following $data = User::with('Address')->find($id_user);

When I submit, I send my form to my controller update public function update(MyRequest $request) that merge both rules (address and user) to create the validation.

The problem: The Address input to work with Form::model, I had to make it as an array like this {!! Form::text('Address[zipcode]', null) !!} and now, my validation doesn't work.

My request looks like this: Array ( [_method] => PATCH [_token] => OlF0IuFxwTIucFavzUB9Sk1IGE5NJlaaarbBxSE [name] => Michel [Address] => Array ( [zipcode] => 80000400))

I was thinking if there is a way to indicate via rule that it should be looked inside the sub-array, something like Address[zipcode] but it didn't work

1 Answer 1

2

Got that working right after I posted the question....

$rules = ['Address.zipcode' => 'required']

Instead of quotes like before, using DOT will make you access the sub-array

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.