Page 1 of 1

SOLVED: Storing Record from Custom Component strips tags

Posted: Sun Feb 10, 2008 4:32 am
by shahpound
Any ideas?

Basically I've written my first component and its working great (or so I thought)! I've imported the editor to the admin area of my components element editing view.

I can updated all the fields including the one I will call "newsletter". The data field is updated through the tinyMCE editor.

If i put any images in the img tag is completely gone by the time it gets stored to the database. I checked the following items:

1) The POST variable actually does have the tags, so tinyMCE is off the hook.
2) I've tried reading out the variables as follows and then immediately dying and the tags are getting to my model
foreach( $_POST as $key=>$val ){
$post[$key] = JRequest::getVar($key, '', 'post', 'string', JREQUEST_ALLOWRAW );
   
}

The only thing thats really left is either:
if(!$row->check())
or
if (!$row->store())

Any help you guys/gals can provide would be great!

Re: Storing Record from Custom Component strips tags

Posted: Sun Feb 10, 2008 4:01 pm
by shahpound
Update: Its still an issue but i also notice it is stripping out
tags and any other html as well....

Re: SOLVED: Storing Record from Custom Component strips tags

Posted: Sun Feb 10, 2008 4:22 pm
by shahpound
Hope this helps someone.

Basically when I was consuming the POST data prior to the bind I had to use this:

$data = JRequest::get( 'post',JREQUEST_ALLOWRAW)

instead of

$data = JRequest::get( 'post')

Afterwards, cycling through all the post variables and attempting to use JREQUEST_ALLOWRAW obviously wasn't working for me because the HTML had already been filtered out.

Doh!

Re: SOLVED: Storing Record from Custom Component strips tags

Posted: Mon Feb 11, 2008 12:47 pm
by Pentacle
$data = JRequest::get('post');
$data['text'] = JRequest::getVar( 'text', '', 'post', 'string', JREQUEST_ALLOWRAW );


This is working perfectly for me. I think you shouldn't get all the post variables with ALLOWRAW unless all the fields you are using requires HTML.

Re: SOLVED: Storing Record from Custom Component strips tags

Posted: Mon Feb 11, 2008 4:48 pm
by shahpound
Pentacle wrote:
$data = JRequest::get('post');
$data['text'] = JRequest::getVar( 'text', '', 'post', 'string', JREQUEST_ALLOWRAW );


This is working perfectly for me. I think you shouldn't get all the post variables with ALLOWRAW unless all the fields you are using requires HTML.


Understood. I was just trying to debug why my tags were being stripped out hence the for loop.