Jump to:

2011 Posts in 1436 Topics by 620 members

Form Questions

SilverStripe Forums » Form Questions » Form creating, submit action problem

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

Page: 1
Go to End
Author Topic: 547 Views
  • snaip
    Avatar
    Community Member
    180 Posts

    Form creating, submit action problem Link to this post

    Hi

    I have problem with form. Submit action doesn't work:

    FormIndex.php

    class FormIndex extends Form {

    function __construct($controller, $name) {
    $fields = new FieldSet(
    new TextField('FirstName', 'First Name'),
    new TextField('Tel', 'Tel'),
    new EmailField('Email', 'Email'),
    new TextareaField('Frage', 'Frage')
    );

    $actions = new FieldSet(
    new FormAction('doForm', 'Submit')
    );

    parent::__construct($controller, $name, $fields, $actions);
    }

    function doForm($data, $form) {
    print_r($data);
    exit;
    // do procedures after form is submitted here
    }

    }

    Start.php

    class Start_Controller extends StaticPage_Controller {

    public static $allowed_actions = array(
    'doForm'
    );

    public function formularz(){
    $form = new FormIndex($this,'FormIndex');
    $form->setFormAction($this->link('doForm'));
    return $form;
    }

    }

    nothing happens, after submit form site is redirecting to /home/doForm but this action doesn't work

    function doForm($data, $form) {
    print_r($data);
    exit;
    // do procedures after form is submitted here
    }

    547 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.