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

Allowed Actions on Forms




15 January 2014 at 8:14pm (Last edited: 15 January 2014 8:16pm), Community Member, 25 Posts

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.