Support the ongoing development of Laravel.io →
Input Forms Laravel
Last updated 1 month ago.
0

Hello Ilhm,

Next time try to place the code in a code block, then it is more readable :)

The error is indeed that the $countries variable doesn't exist. You should give it to the view on the place where you create the view.

Example:

public function create()
{
	// an example, I suspect you can load it from the database or a config file
	$countriesList = [
			'Afghanistan',
			'Albania',
			'Algeria',
	];
	return view('contact.create')
		->with('countries', $countriesList) // this is the place where you create a $countries variable in your view with the content of $countriesList. They can have the same name but to make the example clear I use 2 different names.
		;
}

You can also do

return view('contact.create', ['countries' => $countriesList]);

See the documentation: https://laravel.com/docs/6.x/blade#displaying-data

0

Sign in to participate in this thread!

Full Stack Europe

Your banner here too?

Ilham Ilham ilhm Joined 28 Oct 2019

Moderators

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

Your logo here?

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

© 2022 Laravel.io - All rights reserved.