Reputation: 7737
I'm sending user details to a view with:
$transformed = new User;
$transformed->firstname = $user->firstname;
$transformed->lastname = $user->lastname;
$transformed->email = $user->email;
return View::make('account.settings', ['user' => $transformed]);
if I do dd($transformed)
before View::make
then I see a complete email address, but the template cuts off everything from the "@" and before:
Should be: [email protected]
Is: parent.com
In the blade template, I have:
{{ $user->email }}
Why is it cutting off the start?
Here's the full view file:
@extends('account')
@section('content')
<section class="site-section site-content account-section">
<div class="container">
<h1 class="account-header">Account Settings</h1>
<div class="row">
<div class="col-xs-12 col-md-6">
<form role="form" method="POST" action="/auth/register" class="form-horizontal" autocomplete="off">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<h3>Basic Details</h3>
<div class="form-group">
<div class="col-xs-12">
<label for="register-email">Email address</label>
<input id="register-email" type="text" name="email" class="form-control" autocomplete="off" value="{{ $user->email }}">
</div>
</div>
<div class="form-group">
<div class="col-xs-12">
<label for="register-firstname">First Name</label>
<input id="register-firstname" type="text" name="firstname" class="form-control" autocomplete="off" value="{{ $user->firstname }}">
</div>
</div>
<div class="form-group">
<div class="col-xs-12">
<label for="register-lastname">Last Name</label>
<input id="register-lastname" type="text" name="lastname" class="form-control" autocomplete="off" value="{{ $user->lastname }}">
</div>
</div>
<div class="form-group form-actions">
<div class="col-xs-12">
<button type="submit" class="btn btn-block btn-effect-ripple btn-lg btn-success"><i class="fa fa-plus"></i> Update Details</button>
</div>
</div>
<h3>
</h3>
</form>
</div>
</div>
<!-- END row -->
</div>
</section>
@stop
Upvotes: 4
Views: 957
Reputation: 3811
It appears from the comments that this is a bug in Laravel itself as @parent
, @extends
etc are reserved words in the blade template engine.
A simple work around it to simply replace the @
symbol with it's HTML Entity equivalent (@
). So, please try the following snippet:
{{ str_replace('@', '@', $user->email) }}
This can also be used in mailto
protocol links, as so:
<a href="mailto:{{ str_replace('@', '@', $email) }}">
{{str_replace('@', '@', $email)}}
</a>
For reference, here is a list of all HTML Entities (the list is far too long to add to this answer): http://www.ascii.cl/htmlcodes.htm
Upvotes: 1