Monday, 15 August 2011

php - View make with multiple parameters -



php - View make with multiple parameters -

i working laravel 4 , have page form edit store. send info controller , validate fields. in case wrong homecoming edit page , trying send message , object. not working because can't message. object.

this how homecoming view:

if($validator->fails()) { homecoming view::make('admin.editstore')->with('fail', 'wrong input!!!')->with('store', $store); }

and how message:

@if(session::has('success')) <div class="alert alert-success"> {{ session::get('success') }} </div> @elseif (session::has('fail')) <div class="alert alert-danger"> {{ session::get('fail') }} </div> @endif

in case goes wrong have access object in edit page. can't access message. know problem ? i'm out of ideas ..

ps: part getting message on page should ok because utilize on other pages , it's working. think problem on returning view multiple data, i'm not sure how this..

passing multiple parameters calling ->with() multiple times okay. there no issue there.

however, doesn't view trying access $fail parameter passed it. view looking fail message in session. either need alter view @ $fail parameter passed it, or need alter controller set $fail info in session rather passing view.

also, i'm not sure if meaning create edit view have, or if wanted redirect edit view. if using resourceful route/controller, tend have (only edit/update actions shown):

class storecontroller extends basecontroller { /** * show form editing specified resource. */ public function edit($id) { $store = store::find($id); homecoming view::make('admin.editstore')->with('store', $store); } /** * update specified resource in storage. */ public function update($id) { $rules = store::$rules; // or wherever rules $validator = validator::make(input::all(), $rules); if ($validator->fails()) { // flash fail message , redirect edit form // input , validator error messages session::flash('fail', 'invalid!'); homecoming redirect::action('storecontroller@edit', array($id)) ->withinput() ->witherrors($validator->messages()); } else { // flash success message , redirect wherever you'd // go on success session::flash('success', 'valid!'); homecoming redirect::action('storecontroller@index'); } } }

php laravel laravel-4

No comments:

Post a Comment