I am translating the following string:
<p> {{{ trans('myapp.signup_instructions', [ 'email' => '<strong>'.$invitation->email .'</strong>']) }}}</p>
However on our website we can still see the "<strong>user#domain.com</strong>" as text. We were aiming to convert the just the e-mail parameter in the string into bold text
How can I achieve that?
In Laravel 5 you should use {!! !!} to output variable without escaping:
{!! trans('myapp.signup_instructions', ['email' => '<strong>'.$invitation->email .'</strong>']) !!}
Read more: http://laravel.com/docs/master/upgrade#upgrade-5.0 (Blade Tag Changes section)
PS. This does not related to AngularJS
Related
When i use ckeditor in laravel from my localhost and every post i made, that comes with source code and how can i stop this.
I am new!
{{Form::label('body', 'body')}}
{{Form::textarea('body', '', ['id' => 'article-ckeditor','class' => 'form-control', 'placeholder' => 'Body Text'])}}
When i save my body like : This is Good and nice but actually This is Good and nice this text coming with source code.
Hy you can use the {!! $name->name !!} insted of {{ $name->name }}
I am using Laravel 5.0
I have a method in MyController
public function myMethod($id) {
dd($id);
}
The routes.php file
Route::post('path1/{obj-id}/path2', 'MyController#myMethod');
Route::resource('path1', 'MyController');
In the view file, I am calling the method through a form on submit
{!! Form::open(['action' => ['MyController#myMethod', $myObject->id]]) !!}
Now the problem is, every time I click on Submit I get a 404 error. The URL in the address bar changes to path1/1/path2 as expected, but I get 404.
Where am I going wrong?
I got the solution myself.
Turns out one cannot have a dash (-) inside {} in one's routes.
My route in routes.php was initially
Route::post('path1/{obj-id}/path2', 'MyController#myMethod');
I changed it to
Route::post('path1/{id}/path2', 'MyController#myMethod');
and now everything works fine.
Sorry for missing the - in the original question. Thank you all who tried to help.
You can give your route a name and use this name in form
Route::post('path1/{id}/path2', [
'as' => 'myroute', 'uses' => 'MyController#myMethod'
]);
Now use it at your form like this
Form::open(array('route' => array('myroute', $myObject->id)))
Instead of using {!! Form::open(['action' => ['MyController#myMethod', $myObject->id]]) !!}, you need to use any of these:
{!! Form::open(['url' => 'path1/'.$myObject->id.'/path2']) !!}
Or, if you use Name routes i.e. mymethod.update, you can do it easily with that:
{!! Form::open(['routes' => ['mymethod.update', $myObject->id]]) !!}
BTW, if you really want to use 'action', you need to change your url like this in your routes.php file:
Route::post('path1/path2/{id}', 'MyController#myMethod');
Route::resource('path1', 'MyController');
Hope this help!
The Problem is with your route .
Route::post('path1/{id}', 'MyController#myMethod');
And in View, You missed the Post method . Change your view to below
{!! Form::open(['action' => ['MyController#myMethod', $myObject->id, 'method' => 'post']]) !!}
Hope this helps !
In laravel 5, when I write this in my view:
#include("places.form", ["submitButton" => #lang('crud.updateModel', ['currentModelName' => $currentModelName])])
I get this:
#lang('crud.addModel', ['currentModelName' => Lugar])
How can I do so that it can be interpreted?
Try:
#include("tournaments.form", ["submitButton" => trans('crud.addTournament')])
You will get:
["submitButton" => 'the translated text']
{{ }} and {!! !!} are just a wrapper around <?php echo ?> therefore in all Blade directives you don't have to add it use type as if you are typing in PHP file! use you translation function without curly brackets, and you don't need the double quotations too:
#include("tournaments.form", ["submitButton" => trans('crud.addTournament') ])
I'm using {!! Form::model( $data) !!} to get my edit working dynamically, also I have normal inputs like {!! Form::text('name', null) !!} but, within my controller, before I send my $data to my view, I use with like the following $data = User::with('Address')->find($id_user);
When I submit, I send my form to my controller update public function update(MyRequest $request) that merge both rules (address and user) to create the validation.
The problem:
The Address input to work with Form::model, I had to make it as an array like this {!! Form::text('Address[zipcode]', null) !!} and now, my validation doesn't work.
My request looks like this:
Array ( [_method] => PATCH [_token] => OlF0IuFxwTIucFavzUB9Sk1IGE5NJlaaarbBxSE [name] => Michel [Address] => Array ( [zipcode] => 80000400))
I was thinking if there is a way to indicate via rule that it should be looked inside the sub-array, something like Address[zipcode] but it didn't work
Got that working right after I posted the question....
$rules = ['Address.zipcode' => 'required']
Instead of quotes like before, using DOT will make you access the sub-array
I have a column with datatype of date which is date mutated. I date mutated it so that Laravel will convert it to a Carbon instance and I can use it easily at other places, where I need to convert it into Carbon instance. I am using Model binding in the edit form. As the field is date mutated, on the edit form it appears as "2015-07-29 00:00:00". I need it to be in this format instead: "2015-07-29".
I can't use accessor, as I need it as a Carbon instance at many other places.
I can't explicitly pass value after converting, as I am using the input inside a form partial and I also use it for create.
My workaround is the following:
I am sending a flag while including the view partial in the edit page and using it a condition to have two different code for create and edit.
#if (isset($edit))
{!! Form::text('eta', $order->eta->format('Y-m-d'), ['class' => 'form-control', 'required']) !!}
#else
{!! Form::text('eta', null, ['class' => 'form-control', 'required']) !!}
#endif
Is there a better way?
I think you can avoid from #if and $edit as,
{!! Form::text('eta', ( $order->eta ? $order->eta->format('Y-m-d') : null ) , ['class' => 'form-control', 'required']) !!}