susanBuck / e15-spring22

0 stars 0 forks source link

Project2 - Undefined variable Issue #36

Closed mgarimelHES closed 2 years ago

mgarimelHES commented 2 years ago

I am following the design-c and using the Bookmark sample, trying to pass a variable and getting the 'undefined variable' as shown below -

image

I have following the following steps -

  1. Created a route in the 'web.php' -

image

  1. In the view, the 'Get' method is invoking the method -

image

  1. In the controller, action has been defined and hard coded the value for the 'variable ' as follows -

image

  1. In the view , tried to dump the value after the form -

image

  1. But in the view page, getting the error instead of dumping the variable value -

image

Any pointers will be great!

Thanks

pllealfunes commented 2 years ago

Hi @mgarimelHES,

You try dumping the variable in the controller. What if you get rid of the dump in the view and only keep the the one in the controller?

mgarimelHES commented 2 years ago

Hi @pllealfunes,

Thanks, I am trying to dump the variable in the form (step4) as shown in the class this week. I want to debug if the value has been passed from the controller to the view

Thanks

susanBuck commented 2 years ago

Hi @mgarimelHES -

After doing a redirect and "flashing" data to the session, you need to extract the data from the session using the session() helper. Then the extracted data can be passed to the view. It looks like you're missing these last two steps.

susanBuck commented 2 years ago

For an example see the PageController in Bookmark:

https://github.com/susanBuck/e15/blob/3d09d6798f11ba2730c7822643b1865785653a8c/bookmark/app/Http/Controllers/PageController.php#L19

mgarimelHES commented 2 years ago

Susan,

I have done pretty similar, but it is not working for me, getting the variable not defined issue. I have tried to update the 'Bookmark' using a new variable called 'searchTerms2', same issue. I am struck here more than 2 days, not sure about the issue.

Thanks

mgarimelHES commented 2 years ago

ok, it is resolved, I have modified the 'create' and 'store' actions.

Thanks