Jump to:

2011 Posts in 1436 Topics by 620 members

Form Questions

SilverStripe Forums » Form Questions » Allowed Actions on Forms

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

Page: 1
Go to End
Author Topic: 292 Views
  • Vix
    Community Member
    25 Posts

    Allowed Actions on Forms Link to this post

    This is the first time I have gotten into using URL parameters to control various events and I am having a few problems.

    What I need is to be able to click on a link that opens a lightbox with a contact form inside to contact a specific member.

    I have set up my routes.yml file as follows:

    Name: popuprules
    'contact-pop-up//$Action/$ID': ContactPopUp

    My ContactPopUp.php file:

    class ContactPopUp extends Controller {
       private static $allowed_actions = array(
       public static $url_handlers = array(
    'contactmember/$Action/$ID' => 'contactmember'
       public function contactmember(SS_HTTPRequest $request) {
          $member = Member::currentUserID();
             return $this->ContactForm();
          } else {
             return 'not logged in';
       public function ContactForm(){
          $MemberID = $this->request->param('ID');
          $do = Member::get();
          $do = $do->filter(array('ID' => $MemberID));
          foreach($do as $member){
             $to_email = $member->Email;
          $fields = new FieldList(
             new TextField('Name'),
             new EmailField('Email'),
             new TextField('Subject'),
             new TextField('Phone'),   
             new TextAreaField('Message','Message'),
             new HiddenField('EmailTo', '',$to_email)   
          $actions = new FieldList(
             new FormAction('submitContact', 'Submit')
          $form = new Form($this, 'ContactForm', $fields, $actions);
          return $form;
       function submitContact($data, $form) {
    $from = $data['Email'];
          $to = $data['EmailTo'];
          $subject = 'Enquiry';
          $email = new Email($from, $to, $subject);


    But I keep getting the result

    Action '3' isn't available on class Form.

    Where 3 is the correct user ID I want to access.

    How do I make this available on the form class? Do I need to add something else to the routes.yml file?

    Hoping someone can help.

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.