Jump to:

1999 Posts in 1421 Topics by 613 members

Form Questions

SilverStripe Forums » Form Questions » Did something change in form action execution ?

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

Page: 1
Go to End
Author Topic: 1758 Views
  • walec51
    Avatar
    Community Member
    16 Posts

    Did something change in form action execution ? Link to this post

    Hi,

    I see in the wiki that action methods looked like this:

    function doform($data, $form) {
    // ... you already made this ...
    }

    but in 2.3.2 they seam to be executed like this:

    function doform($httpRequest) {
    // ... you already made this ...
    }

    is this the new default behavior or em I missing something?

  • Willr
    Avatar
    Forum Moderator
    5483 Posts

    Re: Did something change in form action execution ? Link to this post

    No this hasn't changed. You should still use doForm($data, $form) for 2.3 sites. If some has updated the documentation with that change then it is wrong. A major API change like this would not be part of a point release like 2.3.2.

  • walec51
    Avatar
    Community Member
    16 Posts

    Re: Did something change in form action execution ? Link to this post

    Hmmm then I don't understand something.
    My action methods seam to be called with only the HttpRequest argument.
    I look in the the Controller.php to check this and I also see:

       function handleAction($request) {

          //...

          // run & init are manually disabled, because they create infinite loops and other dodgy situations
          if($this->checkAccessAction($this->action) && !in_array(strtolower($this->action), array('run', 'init'))) {
             if($this->hasMethod($methodName)) {
                $result = $this->$methodName($re;'quest);
             //...

    shouldn't the line

    $result = $this->$methodName($request);

    look somewhat like this

    $result = $this->$methodName($data, $form);

    or em I looking in the wrong place ?

  • walec51
    Avatar
    Community Member
    16 Posts

    Re: Did something change in form action execution ? Link to this post

    Just found what caused my problem

    I don't know why but I added my doform method to the $allowed_actions variable. Sorry for the false alarm.

    Meanwhile while doing my first bigger form I stumbled for a few hours with another mistake of mine. I didn't make the form name the same as the name of the controller method that generates it. Could you add a remark on the wiki about this like:

       function Form() {
          return new Form($this,
             // the name of the form MUST be the same
             // as the name of the method that generates it
             "Form",
             new FieldSet(
             //...

    otherwise the $form argument won't get initialized properly in the doform method.

    http://doc.silverstripe.org/doku.php?id=recipes:forms

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