Support the ongoing development of Laravel.io →
Input Forms Validation
Last updated 2 years ago.
0

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>)?

Last updated 2 years ago.
0

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 \.

Last updated 2 years ago.
0

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.

Last updated 2 years ago.
0

So, how can I fix this problem?

Last updated 2 years ago.
0

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.

Last updated 2 years ago.
0

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!

Last updated 2 years ago.
0

Show the code where you include the description form element in your view, and the code that processes the form.

Last updated 2 years ago.
0
<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!

Last updated 2 years ago.
0

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) !!}
Last updated 2 years ago.
0

I'm using laravel 4.2. :((

Last updated 2 years ago.
0

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.

Last updated 2 years ago.
0

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!!!

Last updated 2 years ago.
0

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.

Last updated 2 years ago.
0

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

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

kyllynk kyllynk Joined 4 Jun 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.