Support the ongoing development of Laravel.io →
posted 9 years ago
Blade

Hi all i have an issues with laravel blade template, i have a contact form: Like

<div class="customer">
            <h5>New Customers</h5> 
            {{Form::label('title','Title')}}
            <div class="select">
                {{Form::select('title', array(''=>'Select Type','Mr' => 'Mr','Ms' => 'Ms','Mrs' => 'Mrs','Sir' => 'Sir','Lord'=>'Lord','Dr'=>'Dr','Prof'=>'Prof','Rev'=>'Rev','Other'=>'Other'),null,['id' => 'title'])}}
                {{$errors->first('title','<span class=error>:message</span>')}}
            </div>
            {{Form::label('firstname','First Name')}}
            {{Form::input('text', 'firstname', null, ['id' => 'firstname'])}}
            {{$errors->first('firstname','<span class=error>:message</span>')}}

            {{Form::label('surname')}}
            {{Form::input('text', 'surname', null, ['id' => 'surname'])}}
            {{$errors->first('surname','<span class=error>:message</span>')}}

            {{Form::label('company')}}
            {{Form::input('text', 'company', null, ['id' => 'company'])}}
            {{$errors->first('company','<span class=error>:message</span>')}}
            
            {{Form::label('phone_number')}}
            {{Form::input('text', 'phone_number', null, ['id' => 'phone_number'])}}
            {{$errors->first('phone_number','<span class=error>:message</span>')}}

            {{Form::label('emailaddress','Email Address')}}
            {{Form::email('email',null, ['id' => 'emailaddress'])}}
            {{$errors->first('email','<span class=error>:message</span>')}}

            {{Form::label('password')}}
            {{Form::input('password', 'password', null, ['id' => 'password'])}}
            {{$errors->first('password','<span class=error>:message</span>')}}

            {{Form::label('password_confirmation','Confirm Password')}}
            {{Form::input('password', 'password_confirmation', null, ['id' => 'password_confirmation'])}}
            {{$errors->first('password_confirmation','<span class=error>:message</span>')}}

            {{Form::label('country','Select Your Country')}}
            <div class="select">
                {{Form::select('country',array(''=>'Select country','United Kingdom'=>'United Kingdom','United States' => 'United States','Canada' => 'Canada','Afghanistan' => 'Afghanistan', 'Albania' => 'Albania', 'Algeria' => 'Algeria', 'American Samoa' => 'American Samoa', 'Andorra' => 'Andorra', 'Angola' => 'Angola', 'Anguilla' => 'Anguilla', 'Antarctica' => 'Antarctica', 'Antigua and or Barbuda' => 'Antigua and or Barbuda', 'Argentina' => 'Argentina', 'Armenia' => 'Armenia', 'Aruba' => 'Aruba', 'Australia' => 'Australia', 'Austria' => 'Austria', 'Azerbaijan' => 'Azerbaijan', 'Bahamas' => 'Bahamas', 'Bahrain' => 'Bahrain', 'Bangladesh' => 'Bangladesh', 'Barbados' => 'Barbados', 'Belarus' => 'Belarus', 'Belgium' => 'Belgium', 'Belize' => 'Belize', 'Benin' => 'Benin', 'Bermuda' => 'Bermuda', 'Bhutan' => 'Bhutan', 'Bolivia' => 'Bolivia', 'Bosnia and Herzegovina' => 'Bosnia and Herzegovina','Botswana' => 'Botswana', 'Bouvet Island' => 'Bouvet Island', 'Brazil' => 'Brazil','British lndian Ocean Territory' => 'British lndian Ocean Territory', 'Brunei Darussalam' => 'Brunei Darussalam', 'Bulgaria' => 'Bulgaria', 'Burkina Faso' => 'Burkina Faso', 'Burundi' => 'Burundi', 'Cambodia' => 'Cambodia', 'Cameroon' => 'Cameroon', 'Cape Verde' => 'Cape Verde', 'Cayman Islands' => 'Cayman Islands', 'Central African Republic' => 'Central African Republic', 'Chad' => 'Chad', 'Chile' => 'Chile', 'China' => 'China', 'Christmas Island' => 'Christmas Island', 'Cocos' => 'Cocos', 'Colombia' => 'Colombia', 'Comoros' => 'Comoros', 'Congo' => 'Congo', 'Cook Islands' => 'Cook Islands', 'Costa Rica' => 'Costa Rica', 'Croatia' => 'Croatia', 'Cuba' => 'Cuba', 'Cyprus' => 'Cyprus', 'Czech Republic' => 'Czech Republic', 'Denmark' => 'Denmark', 'Djibouti' => 'Djibouti', 'Dominica' => 'Dominica', 'Dominican Republic' => 'Dominican Republic', 'East Timor' => 'East Timor', 'Ecudaor' => 'Ecudaor', 'Egypt' => 'Egypt', 'El Salvador' => 'El Salvador', 'Equatorial Guinea' => 'Equatorial Guinea', 'Eritrea' => 'Eritrea', 'Estonia' => 'Estonia', 'Ethiopia' => 'Ethiopia', 'Falkland Islands' => 'Falkland Islands', 'Faroe Islands' => 'Faroe Islands', 'Fiji' => 'Fiji', 'Finland' => 'Finland', 'France' => 'France', 'France, Metropolitan' => 'France, Metropolitan', 'French Guiana' => 'French Guiana', 'French Polynesia' => 'French Polynesia', 'French Southern Territories' => 'French Southern Territories', 'Gabon' => 'Gabon', 'Gambia' => 'Gambia', 'Georgia' => 'Georgia', 'Germany' => 'Germany', 'Ghana' => 'Ghana', 'Gibraltar' => 'Gibraltar', 'Greece' => 'Greece', 'Greenland' => 'Greenland', 'Grenada' => 'Grenada', 'Guadeloupe' => 'Guadeloupe', 'Guam' => 'Guam', 'Guatemala' => 'Guatemala', 'Guinea' => 'Guinea', 'Guinea-Bissau' => 'Guinea-Bissau', 'Guyana' => 'Guyana', 'Haiti' => 'Haiti', 'Heard and Mc Donald Islands' => 'Heard and Mc Donald Islands', 'Honduras' => 'Honduras', 'Hong Kong' => 'Hong Kong', 'Hungary' => 'Hungary', 'Iceland' => 'Iceland', 'India' => 'India', 'Indonesia' => 'Indonesia', 'Iran' => 'Iran', 'Iraq' => 'Iraq', 'Ireland' => 'Ireland', 'Israel' => 'Israel', 'Italy' => 'Italy', 'Ivory Coast' => 'Ivory Coast', 'Jamaica' => 'Jamaica', 'Japan' => 'Japan', 'Jordan' => 'Jordan', 'Kazakhstan' => 'Kazakhstan', 'Kenya' => 'Kenya', 'Kiribati' => 'Kiribati', 'Korea' => 'Korea, Democratic People\'s Republic of', 'Korea' => 'Korea, Republic of', 'Kuwait' => 'Kuwait', 'Kyrgyzstan' => 'Kyrgyzstan', 'Lao People' => 'Lao People\'s Democratic Republic', 'Latvia' => 'Latvia', 'Lebanon' => 'Lebanon', 'Lesotho' => 'Lesotho', 'Liberia' => 'Liberia', 'Libyan Arab Jamahiriya' => 'Libyan Arab Jamahiriya', 'Liechtenstein' => 'Liechtenstein', 'Lithuania' => 'Lithuania', 'Luxembourg' => 'Luxembourg', 'Macau' => 'Macau', 'Macedonia' => 'Macedonia', 'Madagascar' => 'Madagascar', 'Malawi' => 'Malawi', 'Malaysia' => 'Malaysia', 'Maldives' => 'Maldives', 'Mali' => 'Mali', 'Malta' => 'Malta', 'Marshall' => 'Marshall Islands', 'Martinique' => 'Martinique', 'Mauritania' => 'Mauritania', 'Mauritius' => 'Mauritius', 'Mayotte' => 'Mayotte', 'Mexico' => 'Mexico', 'Micronesia' => 'Micronesia, Federated States of', 'Moldova' => 'Moldova, Republic of', 'Monaco' => 'Monaco', 'Mongolia' => 'Mongolia', 'Montserrat' => 'Montserrat', 'Morocco' => 'Morocco', 'Mozambique' => 'Mozambique', 'Myanmar' => 'Myanmar', 'Namibia' => 'Namibia', 'Nauru' => 'Nauru', 'Nepal' => 'Nepal', 'Netherlands' => 'Netherlands', 'Netherlands Antilles' => 'Netherlands Antilles', 'New Caledonia' => 'New Caledonia', 'New Zealand' => 'New Zealand', 'Nicaragua' => 'Nicaragua', 'Niger' => 'Niger', 'Nigeria' => 'Nigeria', 'Niue' => 'Niue', 'Norfork' => 'Norfork Island', 'Northern Mariana Islands' => 'Northern Mariana Islands', 'Norway' => 'Norway', 'Oman' => 'Oman', 'Pakistan' => 'Pakistan', 'Palau' => 'Palau', 'Panama' => 'Panama', 'Papua New Guinea' => 'Papua New Guinea', 'Paraguay' => 'Paraguay', 'Peru' => 'Peru', 'Philippines' => 'Philippines', 'Pitcairn' => 'Pitcairn', 'Poland' => 'Poland', 'Portugal' => 'Portugal', 'Puerto Rico' => 'Puerto Rico', 'Qatar' => 'Qatar', 'Reunion' => 'Reunion', 'Romania' => 'Romania', 'Russian Federation' => 'Russian Federation', 'Rwanda' => 'Rwanda', 'Saint Kitts and Nevis' => 'Saint Kitts and Nevis', 'Saint Lucia' => 'Saint Lucia', 'aint Vincent and the Grenadines' => 'Saint Vincent and the Grenadines', 'Samoa' => 'Samoa', 'San Marino' => 'San Marino', 'Sao Tome and Principe' => 'Sao Tome and Principe', 'Saudi Arabia' => 'Saudi Arabia', 'Senegal' => 'Senegal', 'Seychelles' => 'Seychelles', 'Sierra Leone' => 'Sierra Leone', 'Singapore' => 'Singapore', 'Slovakia' => 'Slovakia', 'Slovenia' => 'Slovenia', 'Solomon Islands' => 'Solomon Islands', 'Somalia' => 'Somalia', 'South Africa' => 'South Africa', 'South Georgia South Sandwich Islands' => 'South Georgia South Sandwich Islands', 'Spain' => 'Spain', 'Sri Lanka' => 'Sri Lanka', 'St. Helena' => 'St. Helena', 'St. Pierre and Miquelon' => 'St. Pierre and Miquelon', 'Sudan' => 'Sudan', 'Suriname' => 'Suriname', 'Svalbarn and Jan Mayen Islands' => 'Svalbarn and Jan Mayen Islands', 'Swaziland' => 'Swaziland', 'Sweden' => 'Sweden', 'Switzerland' => 'Switzerland', 'Syrian Arab Republic' => 'Syrian Arab Republic', 'Taiwan' => 'Taiwan', 'Tajikistan' => 'Tajikistan', 'Tanzania' => 'Tanzania, United Republic of', 'Thailand' => 'Thailand', 'Togo' => 'Togo', 'Tokelau' => 'Tokelau', 'Tonga' => 'Tonga', 'Trinidad and Tobago' => 'Trinidad and Tobago', 'Tunisia' => 'Tunisia', 'Turkey' => 'Turkey', 'Turkmenistan' => 'Turkmenistan', 'Turks and Caicos Islands' => 'Turks and Caicos Islands', 'Tuvalu' => 'Tuvalu', 'Uganda' => 'Uganda', 'Ukraine' => 'Ukraine', 'United Arab Emirates' => 'United Arab Emirates', 'United Kingdom' => 'United Kingdom', 'United States minor outlying islands' => 'United States minor outlying islands', 'Uruguay' => 'Uruguay', 'Uzbekistan' => 'Uzbekistan', 'Vanuatu' => 'Vanuatu', 'Vatican City State' => 'Vatican City State', 'Venezuela' => 'Venezuela', 'Vietnam' => 'Vietnam', 'Virigan Islands' => 'Virigan Islands (British)', 'Virgin Islands (U.S.)' => 'Virgin Islands (U.S.)', 'Wallis and Futuna Islands' => 'Wallis and Futuna Islands', 'Western Sahara' => 'Western Sahara', 'Yemen' => 'Yemen','Yugoslavia' => 'Yugoslavia', 'Zaire' => 'Zaire', 'Zambia' => 'Zambia', 'Zimbabwe' => 'Zimbabwe'),null,['id' => 'country'])}}
            </div>
            <div>
                @if(Session::has('flash_message'))
                <p style="font-family:'Roboto'sans-serif;color: green;">{{Session::get('flash_message')}}</p>
                @endif
            </div>

Here is the form shows different fields like title name and all.

But particularly have an issues with select title for contact form.

<div class="select">
                {{Form::select('title', array(''=>'Select Type','Mr' => 'Mr','Ms' => 'Ms','Mrs' => 'Mrs','Sir' => 'Sir','Lord'=>'Lord','Dr'=>'Dr','Prof'=>'Prof','Rev'=>'Rev','Other'=>'Other'),null,['id' => 'title'])}}
                {{$errors->first('title','<span class=error>:message</span>')}}
            </div>

Above my contact form title, it's static but i need to get the dynamic vales i have wrote the controller for this.

public function contact_titles()
	{
		$contact_titles = ContactTitle::all();
                foreach ($contact_titles as $contact) {
                    $view[] = $contact['title'];
                }
               
		return View::make('frontend.auth.login',compact('view'));
	}

Here is my Routes:

Route::get('login',array('as'=>'frontend.index','uses'=>'Frontend\AuthController@contact_titles'));

So i have passed the variable $view to that login form, but the issues with select option values. I can't get the selected vales to the option so i need help for getting the dynamic values to select option tag.

Thanks in Advance.

Last updated 3 years ago.
0
#In your Controller Frontend\AuthController
    public function contact_titles()
    {
        $contact_titles = ContactTitle::lists('title');
        return View::make('frontend.auth.login',compact('contact_titles'));
    }

#And your select Title in the view
    <div class="select">
        {{Form::select('title',  $contact_titles , null,['id' => 'title'])}}
        {{$errors->first('title','<span class=error>:message</span>')}}
    </div>
Last updated 9 years ago.
0

It is also best to separate the countries selection. Either seed those values to a database table and cache them, or just separate them into a different blade view and include it in this view. It's more neat that way

0

Sign in to participate in this thread!

Eventy

Your banner here too?

yokeswar yokeswar Joined 9 Oct 2014

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.

© 2025 Laravel.io - All rights reserved.