Jump to:

2002 Posts in 1422 Topics by 616 members

Form Questions

SilverStripe Forums » Form Questions » Modifying the the attachment process for a User defined form

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1299 Views
  • mschiefmaker
    Avatar
    Community Member
    187 Posts

    Modifying the the attachment process for a User defined form Link to this post

    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

  • mschiefmaker
    Avatar
    Community Member
    187 Posts

    Re: Modifying the the attachment process for a User defined form Link to this post

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

    Thanks

    MM

  • zenmonkey
    Avatar
    Community Member
    527 Posts

    Re: Modifying the the attachment process for a User defined form Link to this post

    Have you tried using

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

    instead of $_GET ?

  • mschiefmaker
    Avatar
    Community Member
    187 Posts

    Re: Modifying the the attachment process for a User defined form Link to this post

    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

    1299 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.