Fabrik Home

Go Back   Fabrik > Fabrik 2.0.x > Bronze Subscriber Support


Notices

Bronze Subscriber Support This is the monitored support forum for Bronze Supporters. Although we do our best to answer all posts in Bronze support on a FIFO basis (First In, First Out) every day, sometimes we simply don't have the time to get to everyone. We leave it up to you to keep your issues on our radar! If you haven't received a response within one working day, it is likely that you will need to "bump" your thread (by posting a short, polite follow-up saying something like "friendly bump"). It also helps everyone if you remember to close your threads once they are resolved (using the Thread Tools menu). You can always re-open them later if need be.

Reply
 
Thread Tools
Old 07-21-2010, 06:11 PM   #1
ejoftheweb
Junior Member
Supporter
 
Join Date: Jun 2010
Posts: 6
Thanks: 2
Thanked 1 Time in 1 Post
ejoftheweb has helped a few Fabrik users
Default php form submission script clues

sweltering, so sorry if the answer to this is obvious, I have looked but not found though may be stupid due to heat....

Using the RunPHP form submission plugin, writing a script...

are the form variable names the same as the fabrik element names?

so could I use:

$value = JRequest::getVar('___fullelementname');

if not, what else do I use to get the data out of $_REQUEST?

Is there any more documentation on writing form submission scripts beyond page 24 in the pdf manual?

ejoftheweb is offline   Reply With Quote


Old 07-21-2010, 07:05 PM   #2
peamak
Senior Member
 
peamak's Avatar
 
Join Date: Dec 2008
Location: Biarritz, France
Posts: 2,031
Thanks: 151
Thanked 281 Times in 245 Posts
peamak is a Fabrik God peamak is a Fabrik God peamak is a Fabrik God peamak is a Fabrik God peamak is a Fabrik God peamak is a Fabrik God peamak is a Fabrik God peamak is a Fabrik God peamak is a Fabrik God peamak is a Fabrik God peamak is a Fabrik God
Send a message via Skype™ to peamak
Default

Yes you can use JRequest::getVar() but you'll need to use the full element name, meaning:
table_name___element_name
With the _raw possibility.

For the other question: I don't think I've ever read the manual but this is a weird question LOL
__________________
-- tom

SVN - Get the plugins
Nightly builds
Fabrik tutorials
HowTo List
Donate (to Fabrik, not to me )
peamak is offline   Reply With Quote
Old 07-22-2010, 09:58 AM   #3
rob
Administrator
 
rob's Avatar
 
Join Date: Jan 2007
Location: La Rochelle France
Posts: 9,628
Thanks: 131
Thanked 437 Times in 413 Posts
rob is a Fabrik God rob is a Fabrik God rob is a Fabrik God rob is a Fabrik God rob is a Fabrik God rob is a Fabrik God rob is a Fabrik God rob is a Fabrik God rob is a Fabrik God rob is a Fabrik God rob is a Fabrik God
Default

Quote:
Yes you can use JRequest::getVar() but you'll need to use the full element name, meaning:
table_name___element_name
Although if your form is not recording to the database then

PHP Code:
$value JRequest::getVar('___fullelementname'); 
is correct

You can always add:

PHP Code:
echo 'value = ' $value;
exit; 
in your script to test that you have picked up the correct data, That line would write out the value and exit allowing you to see the output before the form redirects after the end of the PHP form submission plugin

-Rob
rob is offline   Reply With Quote
Old 07-30-2010, 11:14 AM   #4
ejoftheweb
Junior Member
Supporter
 
Join Date: Jun 2010
Posts: 6
Thanks: 2
Thanked 1 Time in 1 Post
ejoftheweb has helped a few Fabrik users
Default

Thanks both for the reply and the script is now picking up the right values from the form, but despite the cooler weather I still seem to have the stupid goggles on...

The form is accessed using the fabrik cck button and its intended purpose is to add attributes to articles as they are created/edited; these are then stored in a table used by a third-party extension.

I need to get the joomla article_id of the article being edited when the form is called up with the fabrik button, and therefore created a hidden field element called article_id, but I can't work out how to get the value into the field. Do I need to put a fabrik placeholder in the default box for the element - and if so what?

Or perhaps I can access it directly in PHP from the joomla framework, without carrying it back and forth in POST headers?

Hints would be much appreciated. I have tried RTFM, honest!
ejoftheweb is offline   Reply With Quote
Old 07-30-2010, 12:21 PM   #5
peamak
Senior Member
 
peamak's Avatar
 
Join Date: Dec 2008
Location: Biarritz, France
Posts: 2,031
Thanks: 151
Thanked 281 Times in 245 Posts
peamak is a Fabrik God peamak is a Fabrik God peamak is a Fabrik God peamak is a Fabrik God peamak is a Fabrik God peamak is a Fabrik God peamak is a Fabrik God peamak is a Fabrik God peamak is a Fabrik God peamak is a Fabrik God peamak is a Fabrik God
Send a message via Skype™ to peamak
Default

If I understood correctly, you could try something like that:
PHP Code:
$articleId JRequest::getVar('id');
if (
strstr(':'$articleId)) { // article's ID can be of format XX:title-alias
$articleId array_shift(explode(':'$articleId));
}
return 
$articleId
Hope I'm making sense.
__________________
-- tom

SVN - Get the plugins
Nightly builds
Fabrik tutorials
HowTo List
Donate (to Fabrik, not to me )
peamak is offline   Reply With Quote
The Following User Says Thank You to peamak For This Useful Post:
Old 07-30-2010, 02:06 PM   #6
ejoftheweb
Junior Member
Supporter
 
Join Date: Jun 2010
Posts: 6
Thanks: 2
Thanked 1 Time in 1 Post
ejoftheweb has helped a few Fabrik users
Default

Tom, thanks for your quick response.

My problem isn't with the php side of things though. if the value is in the POST request, I can get it: it's how to get it there in the first place, which I think I have to do using fabrik settings on the form or element and can't quite figure out.
ejoftheweb is offline   Reply With Quote
Old 08-02-2010, 12:20 PM   #7
rob
Administrator
 
rob's Avatar
 
Join Date: Jan 2007
Location: La Rochelle France
Posts: 9,628
Thanks: 131
Thanked 437 Times in 413 Posts
rob is a Fabrik God rob is a Fabrik God rob is a Fabrik God rob is a Fabrik God rob is a Fabrik God rob is a Fabrik God rob is a Fabrik God rob is a Fabrik God rob is a Fabrik God rob is a Fabrik God rob is a Fabrik God
Default

What I think you are going to need is to add a hidden field to your form.
Call it article_id
Set it to eval
set its default value to

PHP Code:
return JRequest::getVar('id'); 
When the form is loaded in the article it will insert the article id into the field.

Then when you submit your form you can grab that with

PHP Code:
$articleId JRequest::getVar('article_id'); 
rob is offline   Reply With Quote
The Following User Says Thank You to rob For This Useful Post:
Old 08-02-2010, 04:12 PM   #8
ejoftheweb
Junior Member
Supporter
 
Join Date: Jun 2010
Posts: 6
Thanks: 2
Thanked 1 Time in 1 Post
ejoftheweb has helped a few Fabrik users
Default

Rob, many thanks. I think I'm narrowing this down - slightly more on the ball today too.
Using php code for the default values opens up loads of interesting possibilities....

But, looking at the setup again:

The article_id is in the GET request to open the article editor (its name seems to be cid[], not id), but the form is called using the fabrik_cck button, which generates another http GET request, and this request doesn't contain the article_id.

So I have tracked down fabrik.php in editors.xtd, and edited it so that:

PHP Code:
$link 'index.php?option=com_fabrik&c=form&task=cck&tmpl=component&e_name='.$name.'&catid='.$catid.'&section='.$section
becomes:

PHP Code:
$link 'index.php?option=com_fabrik&c=form&task=cck&tmpl=component&e_name='.$name.'&catid='.$catid.'&section='.$section.'&cid='.$id.; 
and it seems to work...

So thanks for the pointers; I'll be back again shortly when I hit the next gotcha.
ejoftheweb is offline   Reply With Quote
The Following User Says Thank You to ejoftheweb For This Useful Post:
rob
Old 08-04-2010, 02:43 PM   #9
rob
Administrator
 
rob's Avatar
 
Join Date: Jan 2007
Location: La Rochelle France
Posts: 9,628
Thanks: 131
Thanked 437 Times in 413 Posts
rob is a Fabrik God rob is a Fabrik God rob is a Fabrik God rob is a Fabrik God rob is a Fabrik God rob is a Fabrik God rob is a Fabrik God rob is a Fabrik God rob is a Fabrik God rob is a Fabrik God rob is a Fabrik God
Default

hey thanks for reporting what you needed to do to fix things. I'd forgotten about the plugin calling a seperate url.
I've added your fix into the svn code for others to benefit from as well

-Rob
rob is offline   Reply With Quote
Reply

Bookmarks

Tags
form , runphp , submission

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Script Error in Run PHP form submission plug-in. migsby Bronze Subscriber Support 2 02-04-2010 06:27 PM
php script upon form submission drechatin Bronze Subscriber Support 1 01-20-2010 03:32 PM
runPHP script by form submission with variables sent from 3 pull down menus selection SUNNIER Bronze Subscriber Support 22 06-04-2009 09:26 PM
Update Joomla Table - using PHP script on Form Submission festus Subscriber Support 23 07-10-2008 09:21 PM
calling MySQL stored procedure in PHP script on form submission Wisdom Hunter Subscriber Support 22 05-29-2008 06:57 PM

» News
Fabrik 2.0.1 released
Please read this blog... [Read More]
Fabrik 2.0 stable released
Please read this ... [Read More]
» Unfuddle SVN
Project: Fabrik 2.x
Rev Comment
4047 fixed <= / >= url filters were incorrectly quoting numeric values
4046 changed: table group by dropdown in admin now allows you to select the raw version of the element
4045 added: table option to deleted joined data when deleting records fixed: several xhtml strict/css validation issues
4044 fixed: using user element in non default connection, any prefilter set up to use said element would generate an SQL error
4043 changed: db join element's concat statement now run through parsemessageforplaceholder()
4042 fixed: email form plugin. Generated error if sending from admin whilst using an article template
4041 fr-FR admin language file: element plugin - fabrikgooglemap
4040 added: digg & rating elements now work with js turned off fixed: some xhtml strict validation errors
4039 fixed: incorrect quoting of dbjoin table filter autocomplete hidden fields
4038 changed: plugin controller - pluginAjax() - now allows for noajax=1 where by $app does redirect (allows for use of ajax...
Powered by vBadvanced CMPS v3.0.0

All times are GMT. The time now is 02:47 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios