I've created a contact form in laravel 7 and one of the fields is a simple select dropdown, it looks like this:
<select name="subject" id="subject" class="form-control">
<option value="">Select ...</option>
<option value="gen">General</option>
<option value="sales">Sales</option>
</select>
When I send the form, I receive an email with the content the user filled out in the form. When an option is selected, in the email the value is displayed. I'd like to display the actual content of the select option. So not "gen" but "General" should be displayed.
Here is my controller code:
public function contactSubmit(Request $request)
{
$this->validate($request, [
'name' => 'required',
'email' => 'required|email',
'subject' => 'required',
'msg' => 'min:10'
]);
$data = array(
'name' => $request->name,
'email' => $request->email,
'subject' => $request->subject,
'msg' => $request->msg
);
Mail::send('emails.contactemail', $data, function($msg) use($data) {
$msg->from($data['email']);
$msg->to('[email protected]');
$msg->subject('Contact us');
});
}
This is the blade content for the email that is sent out:
<strong>From:</strong> {{$name}}
<br>
<strong>Subject:</strong> {{$subject}}
<br>
<strong>Email:</strong> {{ $email }}
<br><br>
<strong>Message:</strong> <br><br>
{{ $msg }}
<option value="General">General</option>?