Why i am getting this error, here is my controller file,
squared code generate error, if I comment this code It'll save post to database
Here is error when i request to post, it give me error :
I think you are using wrong varaibale it should be $posts->is_public.
check your
{!! Form::open() !!}
{!! Form::close() !!}
under your
{!! Form::hidden('id', $posts->id) !!}
Related
I've a little problem with Laravel, i'm displaying my errors like that :
{!! $errors->first('email', '<small class="help-block">:message</small>') !!}
But the error I get is : validation.unique
Do you know the reason ? Is it because i must to write all errors by myself ?
Thanks by advance ;)
I think if you need just error message then you do not need to pass additional field. :message
You can do it by just passing column name.
{{ $errors->first('email') }}
Laravel validation
Try this one
#if($errors->has('email'))
{{ $errors->first('email') }}
#endif
So i have a <textarea> in my form. User can either enter a new line or single line. So when the user views the text it will be showed like how he/she inputs it.
Form
<textarea name="jo_unit" class = 'form-control' required="required" cols = '4'></textarea>
Expected Output
TESTING 1 TESTING 2 TESTING 3
What i get
My code on displaying it
{{ nl2br(#$get['result'][0]->jo_unit_2) }}
Security: This code allows XSS attacks and is not production ready.
use {!! !!}:
{!! nl2br(#$get['result'][0]->jo_unit_2) !!}
Use
{!! nl2br(e(#$get['result'][0]->jo_unit_2)) !!}
{!! !!} creates an escaped output and allows HTML (and XSS attacks).
To make it secure again you also need to use e() see helpers documentation.
I'm struggling with Laravel 5.1 LTS's requests. Every time I upload a file, I get the file name from $request->input('input_file'), but
$request->hasFile('input_file') is false and
$request->file('input_file') is null.
Frontend
{!! \Form::input('file','input_file',null,['style'=>'display:none;']) !!}
which translates to
<input type="file" name="input_file" id="input_file" style="display:none;">
Don't forget to add enctype="multipart/form-data" to your <form> element.
If you're using Laravel Collective's Form/Html package, you can pass 'files' => true to the array:
{!! Form::open(['files' => true]); !!}
I think you are missing 'files'=>'true'
Try this,
Form::open(array('url' => '/uploadfile','files'=>'true'));
I am using Laravel 5 and I need to call a destroy Method inside my edit view.
All examples I found cover this separated with an index view and two buttons (one for editing and one for deleting).
Can somebody give me a hint to call a destroy Method inside an edit view?
You can put this code anywhere, not just in index view. Just create a link and use get route or use destroy route with form button to send a request:
{!! Form::open(['method' => 'Delete', 'route' => ['someroute.destroy', $id]]) !!}
<button type="submit">Delete</button>
{!! Form::close() !!}
Put this in the show view of the item
<form action="{{ route('posts.destroy', $post->id) }}" method="POST">
{{ method_field('DELETE') }}
{{ csrf_field() }}
<button class="btn btn-danger">Delete Post</button>
</form>
{!! Form::label('Date:') !!}
{!! Form::input('date','start',null,['class'=> 'form-control'])!!}