Support the ongoing development of Laravel.io →
Input Forms Laravel
Last updated 2 years ago.
0
moderator

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!

Eventy

Your banner here too?

Ilham ilhm Joined 28 Oct 2019

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.