At a guess I'd say you might be confusing redactor with the following code and it is trying to clean it up:
<p><p><img src="http://localhost/en/elearning/uploads/img/route-filter.png" style=""></p><p>
Why are you nesting a paragraph within another (<p><p>)?
HI sitesense, This code is automatic generate by redactor. In WYSIWYG context, I just add a picture and a link only.
In short, if I insert an image, Laravel will auto replace " to " and \ to \.
The problem could be that your server has magic quotes on unless you're using addslashes() on the input.
Either way, the quotes in your code are being escaped.
Odd though because magic quotes was deprecated in PHP 5.3 and removed in PHP 5.4 which is a requirement for Laravel 4.
First check your php.ini file and ensure that magic quotes is turned off:
magic_quotes_gpc = Off
If that isn't causing your problem, then are you escaping inputs by using addslashes()?
If you can't figure it out, a workaround for now might be to use stripslashes() on your description input:
$myVar = stripslashes(Input:: get('yourDescriptionField');
If you need any more help, you're going to need to tell us what version of PHP you are running and supply some code, particularly the code that reads your input.
sitesense said:
First check your php.ini file and ensure that magic quotes is turned off:
magic_quotes_gpc = Off
If that isn't causing your problem, then are you escaping inputs by using addslashes()?
If you can't figure it out, a workaround for now might be to use stripslashes() on your description input:
$myVar = stripslashes(Input:: get('yourDescriptionField');
If you need any more help, you're going to need to tell us what version of PHP you are running and supply some code, particularly the code that reads your input.
Thanks sitesense, In my php.ini file magic_quotes_gpc is off. And I'm using ->withInput() so how can I strpslashes? :(
My PHP version is: 5.4.7.
All WYSIWSG got this problem in my case. Help me please!
Show the code where you include the description form element in your view, and the code that processes the form.
<div class="app-form-control media">
<div class="app-form-label pull-left">
{{Lang::get('user.description')}}
</div>
<div class="app-form-input media-body">
{{Form::textarea('description',$teacher->description)}}
</div>
<div class="clearfix"></div>
<script>
$(function(){
$('textarea[name=description]').redactor({
imageUpload : '{{route('admin_upload_image')}}'
});
});
</script>
</div>
In the Controller if validator return false => Do nothing and return:
return Redirect::route('edit_teacher', array($teacher->ID))->withErrors($valid)->withInput();
Thanks so much Sitesense!
Just a quick one, I need to go out, but if you are using Laravel 5 try changing this:
//{{Form::textarea('description',$teacher->description)}}
{!! Form::textarea('description',$teacher->description) !!}
Ok, since I can't see the whole code (where you read the input), try this as a workaround until you figure out what is escaping the data in the first place:
// add this line to modify the input array before redirecting
Input::merge(array('description', stripslashes(Input::get('description'))));
return Redirect::route('edit_teacher', array($teacher->ID))->withErrors($valid)->withInput();
See how that goes.
sitesense said:
Ok, since I can't see the whole code (where you read the input), try this as a workaround until you figure out what is escaping the data in the first place:
// add this line to modify the input array before redirecting Input::merge(array('description', stripslashes(Input::get('description')))); return Redirect::route('edit_teacher', array($teacher->ID))->withErrors($valid)->withInput();
See how that goes.
Thanks so much sitesense!
Your solution work for me. But you have a small mistake:
Input::merge(array('description' => stripslashes(Input::get('description'))));
// NOT
Input::merge(array('description', stripslashes(Input::get('description'))));
Thank again!!!
Oops, my bad. Glad you got it working :)
Just be careful though, because when you save that to the database (when validation succeeds), the slashes will still be in there. You might need to remove them before saving.
sitesense said:
Oops, my bad. Glad you got it working :)
Just be careful though, because when you save that to the database (when validation succeeds), the slashes will still be in there. You might need to remove them before saving.
Yup! I'm already strip slashes before update database. :D
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community