Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Form Questions /

Modifying the the attachment process for a User defined form


Reply


4 Posts   1388 Views

Avatar
mschiefmaker

Community Member, 187 Posts

19 September 2009 at 5:33pm

Edited: 19/09/2009 5:36pm

Hi
When I call a user defined form I pass a variable in the URL www.blah.com/contactform?mfid=4

I want to use this variable within the UserDefinedForm.php to enable me to change what attachment gets sent with the response to the submitter i.e. want to add this (at about line 400)

         $fn = DataObject::get_by_id("MonkeysFist", $_GET['mfid']);
if(!$fn) return false;
         $filepath = "assets/Uploads/mf_attachments/$fn->MFFileName";
         $emailToSubmiter->attachFile($filepath, $fn->MFFileName);

At the moment $_GET['mfid'] returns no value and I am wondering how I can pass it into this script?

I know I should not be necessarily adding it to this file as it would become an upgrade issue but I am no worrying about that at the moment. I just want to see if I can get it to work.

How do I go about this?

Thanks
MM

Avatar
mschiefmaker

Community Member, 187 Posts

22 September 2009 at 9:39pm

Any thoughts on this. I still can't see a way to do it?

Thanks

MM

Avatar
zenmonkey

Community Member, 532 Posts

1 October 2009 at 4:08pm

Have you tried using

Director::urlParams[’mfid’] or $_REQUEST['mfid']

instead of $_GET ?

Avatar
mschiefmaker

Community Member, 187 Posts

8 November 2009 at 12:52pm

Thanks for this suggestion.

I am having problem implementing it though. I am trying to use

$mfid= (int)Director::urlParams['ID'];
$fn = DataObject::get_by_id("MonkeysFist", $mfid);

I get Parse error: syntax error, unexpected '[' in ... for the first line

Can anyone tell me why I can't use [ ?

Thanks

MM