[TYPO3-english] formhandler

Reinhard Führicht rf at typoheads.at
Tue Dec 6 19:00:30 CET 2011


On 06.12.2011 14:30, Lamb, Brian wrote:
> Hi all,
>
> I'm migrating from the old mailformplus extension to the new formhandler extension. I've been using the website http://www.typo3-formhandler.com/ which has a good bit of documentation but it doesn't quite answer all of my questions.
>
> With mailformplus, I could call a PHP script when the form was submitted like so,
>
> plugin.tx_thmailformplus_pi1.saveUserFunc = fileadmin/template/main/scripts/php/class.form_processing.inc:form_processing->post_process
>
> Is there a way to do that with formhandler? I can replicate most of what that script does with TS but not everything and I think it would be easier to set a couple of the variables like where the email goes inside a PHP script.
>
> That leads me to my next question. On http://www.typo3-formhandler.com/documentation/articles-howtos/a/how-to-set-up-a-multistep-form-with-conditions/, it demonstrates how you can use conditionals to set different variables. My question is is this specific to formhandler or can this just general typoscript. Either way, if there is more documentation about this, that would be fantastic. I have something in place but it seems very convoluted and there has to be a better way to do it that the way I'm doing it. Specifically, I'm looking to set up an if, else/if, else/if, else/if, else type structure.
>
> Thanks for all the assistance.
>
> Brian Lamb

Hi Brian,

as Stano said, you have to write your own saveInterceptor.

The easiest way to do this:

* Create the interceptor somewhere in fileadmin (e.g. 
fileadmin/script/Tx_Formhandler_Interceptor_MyInterceptor).

* Write the PHP code:

class Tx_Formhandler_Interceptor_MyInterceptor extends 
Tx_Formhandler_AbstractInterceptor {

   public function process() {
     print $this->settings['param1'];

     return $this->gp
   }

}

* Tell Formhandler where to search for custom components:

plugin.Tx_Formhandler.settings(.predef.myForm) {
   additionalIncludePaths.1 = fileadmin/scripts/
}

* Use the class:

plugin.Tx_Formhandler.settings(.predef.myForm) {
   saveInterceptors {
     1 {
       class = Interceptor_MyInterceptor #You can omit the "Tx_Formhandler_"
       config {
         param1 = asdf
       }
     }
   }
}

As you can see, the settings made in the "config" section of the 
interceptor are available in $this->settings in the PHP code.

The submitted data is accessible in $this->gp.

Make sure the interceptor returns $this->gp or your form will not work 
anymore.

Regarding the if/else config for Formhandler:

This is no standard TypoScript code. This is for Formhandler only.

I hope this helps.

Regards,
Reinhard


More information about the TYPO3-english mailing list