SOLVED: Storing Record from Custom Component strips tags

Have a programming question regarding your component, plug-in, extension or core hacks? Have an interesting tidbit, FAQ or programming tip you’d like to share? This is the place for you.

Moderators: tjay, seadap, Rogue4ngel, matthewhayashida

Post Reply
shahpound
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Sat Jan 05, 2008 10:23 pm
Location: Cambridge, MA

SOLVED: Storing Record from Custom Component strips tags

Post by shahpound » Sun Feb 10, 2008 4:32 am

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!
Last edited by shahpound on Sun Feb 10, 2008 4:20 pm, edited 1 time in total.

shahpound
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Sat Jan 05, 2008 10:23 pm
Location: Cambridge, MA

Re: Storing Record from Custom Component strips tags

Post by shahpound » Sun Feb 10, 2008 4:01 pm

Update: Its still an issue but i also notice it is stripping out
tags and any other html as well....

shahpound
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Sat Jan 05, 2008 10:23 pm
Location: Cambridge, MA

Re: SOLVED: Storing Record from Custom Component strips tags

Post by shahpound » Sun Feb 10, 2008 4:22 pm

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!

User avatar
Pentacle
Joomla! Intern
Joomla! Intern
Posts: 61
Joined: Wed Oct 25, 2006 12:34 pm
Location: Turkey

Re: SOLVED: Storing Record from Custom Component strips tags

Post by Pentacle » Mon Feb 11, 2008 12:47 pm

$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.
My Joomla! 1.5 extensions - http://joomla.ercan.us
Progress is made by lazy men looking for easier ways to do things.

shahpound
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Sat Jan 05, 2008 10:23 pm
Location: Cambridge, MA

Re: SOLVED: Storing Record from Custom Component strips tags

Post by shahpound » Mon Feb 11, 2008 4:48 pm

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.


Post Reply