I am using laravel5.2 but after using this code:
{!! Html::image(asset('/images/t1.png'),'',['class'=>'img-rounded']) !!}
The image is not shown.
You can try:
{!! Html::image(asset('/dist/images/t1.png'), '', ['class'=>'img-rounded']) !!}
Try this
{!! Html::image(url('/dist/images/t1.png'),'',['class'=>'img-rounded']) !!}
or
{!! Html::image(URL::asset('/dist/images/t1.png'),'',['class'=>'img-rounded']) !!}
Related
I am already inside a {!! !!}
{!! do_shortcode('[searchandfilter id="27"]') !!}
I am now passing data to this partial file, and need to update that id=""
My thought was to add: {{ }} however it's not printing out because I am already inside of the {!! !!}.
{!! do_shortcode('[searchandfilter id="{{ $form_id }}"]') !!}
Any idea how to concatenate this $form_id inside this blade echo?
Solved it, forgot to try the regular concatenation method:
{!! do_shortcode('[searchandfilter id="'. $form_id .'"]') !!}
Actually, the issue is that you used simple quotes ''. PHP doesn't parse PHP variables inside those.
The following options should work:
{!! do_shortcode("[searchandfilter id='{$form_id}']") !!}
or
{!! do_shortcode("[searchandfilter id='$form_id']") !!}
I'm having a problem. I create form by laravel. I'm working with text field succesfully but when working with password field = error. Who help me? Thank guys.
{!! Form::open() !!}
{!! Form::label('name','Username') !!}
{!! Form::text('txtname','',array('class'=>'user')) !!}
{!! Form::label('pass','Password') !!}
{!! Form::password('txtpass','',array('class'=>'user')) !!}
{!! Form::close() !!}
Form Password does not have value parameter. So the correct form is:
{!! Form::password('txtpass', array('class'=>'user')) !!}
Please Change the Line of password Field to this
{!! Form::password('txtpass',array('class'=>'user')) !!}
I am getting this error from a login page
Action App\Http\Controllers\Admin\LoginController#authenticate not defined. (View: /Applications/XAMPP/xamppfiles/htdocs/lectureme/resources/views/admin/login.blade.php)
I know for certain that this controller exists though, so why is it unable to find it? I have also created a new controller in the controller root and named it TestController, and tried routing to that instead, but that was also apparently not found.
Any suggestions for how to get access to the controller? Form code:
{!! Form::open(['action' => 'LoginController#authenticate']) !!}
<div class="form-group">
<div class="form-group">
{!! Form::label('username', 'Username:') !!}
{!! Form::text('username', null, ['class'=>'form-control']) !!}
</div>
<div class="form-group">
{!! Form::label('email', 'Email Address:') !!}
{!! Form::text('email', null, ['class'=>'form-control']) !!}
</div>
</div>
<div class="form-group">
{!! Form::submit('Login', ['class'=>'btn btn-primary']) !!}
</div>
{!! Form::close() !!}
I have also tried composer dump-autoload and php artisan cache:clear
Make sure you namespaced your controller properly. Assuming you have placed your controller in the App\Http\Controllers\Admin directory it would be:
namespace App\Http\Controllers\Admin
I'm trying to implement checkbox and laravel collective in my form but I get only single value in form, any ideas how to fix it
{!! Form::open(array('action'=>'UserController#updateInfo','method'=>'post')) !!}
Workdays:
<br>
{!! Form::label('monday', 'Monday') !!}
{!! Form::checkbox('workday', 'monday') !!}
<br>
{!! Form::label('tuesday', 'Tuesday') !!}
{!! Form::checkbox('workday', 'tuesday') !!}
<br>
{!! Form::label('wednesday', 'Wednesday') !!}
{!! Form::checkbox('workday', 'wednesday') !!}
<br>
{!! Form::label('thursday', 'Thursday') !!}
{!! Form::checkbox('workday', 'thursday') !!}
<br>
{!! Form::label('friday', 'Friday') !!}
{!! Form::checkbox('workday', 'friday') !!}
<br>
{!! Form::label('saturday', 'Saturday') !!}
{!! Form::checkbox('workday', 'saturday') !!}
<br>
{!! Form::label('sunday', 'Sunday') !!}
{!! Form::checkbox('workday', 'sunday') !!}
<br>
{!! Form::submit('Save', $attributes = ['class'=>'button']) !!}
{!! Form::close() !!}
when I print my request i only get single output (eg. selected monday friday I get only friday when request is processed)
also labels not working - ideas on that too?
You're using the same name (workday) for all your checkboxes. That's why it's only showing the last checkbox with that name
Just change all names to workday[] instead.
{!! Form::checkbox('workday[]', 'monday') !!}
This will return all selected checkbox in an array.
Try this:
You used same name for every checkbox when you checked multiple checkbox you only get the last value.
{!! Form::open(array('action'=>'UserController#updateInfo','method'=>'post')) !!}
Workdays:
<br>
{!! Form::label('monday', 'Monday') !!}
{!! Form::checkbox('workday[]', 'monday') !!}
<br>
{!! Form::label('tuesday', 'Tuesday') !!}
{!! Form::checkbox('workday[]', 'tuesday') !!}
<br>
{!! Form::label('wednesday', 'Wednesday') !!}
{!! Form::checkbox('workday[]', 'wednesday') !!}
<br>
{!! Form::label('thursday', 'Thursday') !!}
{!! Form::checkbox('workday[]', 'thursday') !!}
<br>
{!! Form::label('friday', 'Friday') !!}
{!! Form::checkbox('workday[]', 'friday') !!}
<br>
{!! Form::label('saturday', 'Saturday') !!}
{!! Form::checkbox('workday[]', 'saturday') !!}
<br>
{!! Form::label('sunday', 'Sunday') !!}
{!! Form::checkbox('workday[]', 'sunday') !!}
<br>
{!! Form::submit('Save', $attributes = ['class'=>'button']) !!}
{!! Form::close() !!}
You're using the same name (workday) for all your checkboxes. That's why it's only showing the last checkbox with that name
{{ Form::checkbox('workday[]', 'monday') }}
Hello I'm new to laravel 5.2 and going through some lessons.
For some reason form model binding is not working for me.
{!! Form::model($post, ['method'=>'PATCH', 'action'=> ['PostController#update', $post->id]]) !!}
I received data in $post because I'm using a workaround like this:
{!! Form::text('title', "$post->title" ,['class'=> 'form-control']) !!}
And that is showing my data.
Controller:
namespace App\Http\Controllers;
use App\Post;
use Illuminate\Http\Request;
use App\Http\Requests;
class PostController extends Controller{
public function update(Request $request, $id){
$post =Post::findOrfail($id);
$post->update($request->all());
return redirect('/posts');
}
}
create.blade.php view:
#section('content')
<h1>Create Post</h1>
{!! Form::open(['method'=>'POST', 'action'=>'PostController#store']) !!}
<!-- Title Form Input -->
<div class="form-group">
{!! Form::label('title', 'Title:') !!}
{!! Form::text('title', 'null', ['class'=> 'form-control']) !!}
</div>
<!-- Form Input -->
<div class="form-group">
{!! Form::submit('Create Post', ['class'=> 'btn-primary form-control']) !!}
</div>
{!! Form::close() !!}
#endsection
You shouldn't be quoting the value for null in your input:
{!! Form::text('title', 'null', ['class'=> 'form-control']) !!}
should be
{!! Form::text('title', null, ['class'=> 'form-control']) !!}
Ok, try adding the body of the form into a partial called posts/partials/form.blade.phpand include it between the form open / model and form close tags.
Example:
posts/partials/form.blade.php
<!-- Title Form Input -->
<div class="form-group">
{!! Form::label('title', 'Title:') !!}
{!! Form::text('title', 'null', ['class'=> 'form-control']) !!}
</div>
<!-- Form Input -->
<div class="form-group">
{!! Form::submit($formButtonText, ['class'=> 'btn-primary form-control']) !!}
</div>
posts/create.blade.php
{!! Form::open(['method'=>'POST', 'action'=>'PostController#store']) !!}
#include('posts.partials.form', [
'formSubmitButtonText' => 'Create Post'
])
{!! Form::close() !!}
posts/edit.blade.php
{!! Form::model($post, ['method'=>'PATCH', 'action'=> ['PostController#update', $post->id]]) !!}
#include('posts.partials.form', [
'formSubmitButtonText' => 'Update Post'
])
{!! Form::close() !!}