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') ])
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 !
i'm trying to use this link http://laravelcollective.com to install HTML and Form helper on laravel 5, after install that with composer like with
"require": {
"laravelcollective/html": "~5.0"
}
and update composer i'm add this lines on app.php file:
'providers' => [
/* -------- */
'Collective\Html\HtmlServiceProvider',
],
'aliases' => [
/* -------- */
'Form' => 'Collective\Html\FormFacade',
'Html' => 'Collective\Html\HtmlFacade',
],
and use from Html on view like with :
{{!! HTML::image(Captcha::img(), 'Captcha image',array('id'=>'captcha')) !!}}
I get this error:
Class 'HTML' not found
It's case-sensitive.
You need to change it to something like:
Html::image(Captcha::img(), 'Captcha image',array('id'=>'captcha'))
Also, use double curly braces {{ }} if you want to escape your HTML. In this case, you probably want to use {!! !!}. I'm not sure why you are doing both.
Edit: As noted by #ceejayoz, you can change the alias if you want to. So, for example, if you change your alias in your config/app.php file to all caps like this:
'HTML' => 'Collective\Html\HtmlFacade',
Then, you can do this (to reflect your alias):
{!! HTML::image(Captcha::img(), 'Captcha image',array('id'=>'captcha')) !!}
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
I got an answer previously to my question about how to create edit/update details form in laravel, and the answer was utilizing Form::model(modelName). Nevertheless, the page which is updating is the same page handling the insertion. I have the following form opening:
{{ Form::open(array('action' => 'SomeController#basic','files' => true)) }}
how can I change this to use the form::model instead? I also have an upload of file in same page (profile pic).
Laravel 4 or 5 Form <-> Model binding
Maybe is a "bit" late for the original poster, but for those who search for a solution, this can be used as a later reference.
The L4 solution is:
{{ Form::open($object, array('method' => 'PATCH', 'action' => array('SomeController#update', $object->id),'files' => true)) }}
For Laravel 5, you would use:
{!! Form::model($object, ['method' => 'PATCH', 'action' => ['ObjectsController#update', $object->id], 'files' => true]) !!}
Home this helps!
Form model binding can be done by declaring form open as
{{ Form::model($user, array('action' => 'SomeController#post', 'files'=> true)) }}
You pass the model to the view for example here $user is the model.
$user = User::find(1);
return View::make('editUser')->with(compact('user'));
For file upload, if the $user is isset you could display the image. Along with the upload button. When update is clicked you can check
if(Input::has('file'))
then move the file and upload the path in the database. May be there is a different solution for this.
Is this what you were looking for?