 |
07-21-2010, 06:11 PM
|
#1
|
|
Junior Member
Supporter
Join Date: Jun 2010
Posts: 6
Thanks: 2
Thanked 1 Time in 1 Post
|
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?
|
|
|
07-21-2010, 07:05 PM
|
#2
|
|
Senior Member
Join Date: Dec 2008
Location: Biarritz, France
Posts: 2,031
Thanks: 151
Thanked 281 Times in 245 Posts
|
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 
|
|
|
07-22-2010, 09:58 AM
|
#3
|
|
Administrator
Join Date: Jan 2007
Location: La Rochelle France
Posts: 9,628
Thanks: 131
Thanked 437 Times in 413 Posts
|
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
|
|
|
07-30-2010, 11:14 AM
|
#4
|
|
Junior Member
Supporter
Join Date: Jun 2010
Posts: 6
Thanks: 2
Thanked 1 Time in 1 Post
|
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!
|
|
|
07-30-2010, 12:21 PM
|
#5
|
|
Senior Member
Join Date: Dec 2008
Location: Biarritz, France
Posts: 2,031
Thanks: 151
Thanked 281 Times in 245 Posts
|
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.
|
|
|
|
The Following User Says Thank You to peamak For This Useful Post:
|
|
07-30-2010, 02:06 PM
|
#6
|
|
Junior Member
Supporter
Join Date: Jun 2010
Posts: 6
Thanks: 2
Thanked 1 Time in 1 Post
|
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.
|
|
|
08-02-2010, 12:20 PM
|
#7
|
|
Administrator
Join Date: Jan 2007
Location: La Rochelle France
Posts: 9,628
Thanks: 131
Thanked 437 Times in 413 Posts
|
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');
|
|
|
|
The Following User Says Thank You to rob For This Useful Post:
|
|
08-02-2010, 04:12 PM
|
#8
|
|
Junior Member
Supporter
Join Date: Jun 2010
Posts: 6
Thanks: 2
Thanked 1 Time in 1 Post
|
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.'§ion='.$section;
becomes:
PHP Code:
$link = 'index.php?option=com_fabrik&c=form&task=cck&tmpl=component&e_name='.$name.'&catid='.$catid.'§ion='.$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.
|
|
|
|
The Following User Says Thank You to ejoftheweb For This Useful Post:
|
|
08-04-2010, 02:43 PM
|
#9
|
|
Administrator
Join Date: Jan 2007
Location: La Rochelle France
Posts: 9,628
Thanks: 131
Thanked 437 Times in 413 Posts
|
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
|
|
|
 |
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
» 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... |
|