January 25, 2012

Taming TYPO3 4.6's forms: Implementing a Webhook PostProcessor

At the OOP 2012 I am going to talk about integrating different cloud services by using Webhooks. Webhooks are HTTP callbacks that are triggered by certain events (http://www.webhooks.org).

For one of my live demos I want to integrate a contact form, rendered by the TYPO3 CMS, with Highrise, Zendesk and Dropbox. The trigger is a user, filling out and submitting the contact form. While it would have been trivial to directly send the web form to the integration script, I choose a different path. From TYPO3 4.6 on, the form extension allows configuration of so-called post processsors. These are PHP classes instantiated and invoked after the user has submitted the form without any validation errors.

The default post processor is the mail post processor (class tx_form_System_Postprocessor_Mail). Its purpose is to send all form data via email to the configured recipient. Unfortunately, this is the only post processor available at the moment. What I need is a post processor that sends all data as a POST request to another configured URL, the place where my integration logic is located. By the way, this approach comes much closer to the idea of (Web)hooks. The hook simply extends standard form functionality.

During implementation some obstacles have occured:
1. All post processors must be placed in a certain directory of the form extension
2. You have to deal with a complex domain model (cannot work with the request directly)
3. The post data was encrypted with "multiform/post-data"

1. In the following excerpt of class tx_form_System_Postprocessor (file typo3/sysext/form/Classes/System/Postprocessor/Postprocessor.php) which is part of the form extension, you can see how post processors are looked up, instantiated and processed.

Because the form extension is an extbase extension, the full qualified class names reflect the extension's folder structure. Hence, my Webhook post processor (tx_form_System_Postprocessor_Webhook) must be located in the same folder. This is generally not desireable, because in order to extend the extension I must change it. Real extensibility is planned for TYPO3 4.7 as described in a ticket (http://forge.typo3.org/issues/32701).

2. The form extension is based on extbase, the new (TYPO3 5 way) framework for extensions. It comes with a domain driven design approach, resulting in each extension having the domain model in its center. All requests are automatically mapped to the domain model. This is generally a good thing. But In my example, the principally simple task "resend the form data somewhere else" ended up in long investigation of how the domain model ticks. These are my findings:
  • The model used for the form definition in the backend is tx_form_Domain_Model_Form. It contains all field definitions including their names, types and validation rules.
  • The same structure is later reused when the user submits the form; the actual values are integrated.
  • Each field type is handled differently and has it's own domain class: 
    • normal input - tx_form_Domain_Model_Element_Textline, 
    • select - tx_form_Domain_Model_Element_Select, 
    • textarea - tx_form_Domain_Model_Element_Textarea
  • Not only the real form fields are part of the model, but also container elements like fieldsets.
This results in the following snippet (tx_form_System_Postprocessor_Webhook). It only handles those field types correctly that are used in the demo, namely input, select and textarea elements.

3. After overcoming the above mentioned hurdles, I found out that my POST request sent via CURL is encoded "multiform/post-data". The script handling the web hook has to deal with this fact. I have not changed the encoding because it is generally possible to resend uploaded files also.

To sum up, it is now possible to not only send submitted form data via mail, but also via another POST request. More and more services should offer Webhooks in order to bring powerful and flexible integration scenario to life.


  1. Schade, dass Sie keinen Donate Button haben! dann werde
    ich erstmal einen Bookmark setzen und bei Facebook Ihren Link integrieren.
    Ich würde ganz gerne eine kleinigkeit für Ihren bemerkenswerten Blog spenden.

    Ich freue mich bereits auf weitere Artikel.

    Here is my web-site - Homepage gestalten lassen nrw (www.homepagegestalten.net)

    1. Thank you very much for the kind words. I currently think about further posts and the donate button (-;

  2. Come in and win right now. best slot machines Do not lose your luck.

  3. Best casino bonus codes 2021 | Free spins no deposit
    Find a list of the casino bonus https://deccasino.com/review/merit-casino/ codes and promotions for United communitykhabar Kingdom players. Discover bonus codes for casinos with free spins no deposit on registration.‎How many free spins do you receive from the casino? · ‎What are febcasino the bonuses for United herzamanindir Kingdom players? · ‎What are the free spins worrione and promotions for United Kingdom players?

  4. Also, all gambling sites and our guides are rated 18+ only. So, to seek out|to search out} the most effective slots for yourself, you’ll want to determine out} the kind you want to play, whether or not that’s 5-reel slots, classics, 3D, progressive, and so on. Ignition also has something for its current gamers, together with the Weekly Boost, the Ignition Rewards loyalty program, crypto month-to-month giveaway, and more. Both of these incentives arrive with 25x wagering necessities, which is among the many lowest on our list of slot sites. Use the link above and code IRONBORDERS to get a 245% match bonus and 55 free spins. 점보카지노 Slots.lv excels plenty of} areas but none more than their rewards and bonuses part.

  5. If you are still undecided as as to if want to} attempt it, simply take into consideration how many of} online slots out there characteristic the legendary picture of Ozzy biting the top of a bat. It grants pretty much anything find a way to|you presumably can} think about, from cash to free spins bonus rounds, to a jackpot bonus. By accessing and half in} this sport, you agree to future sport updates as launched on this web site. You may choose to update this sport, but 1xbet when you do not update, your sport experience and functionalities could also be} reduced.

  6. However, the general variety of empirical research within this research area continues to be restricted. Prior research aimed to handle the nexus between enterprise model and expertise and assumed that the Sweater Dresses for Girls 2 intently related. The current examine goals to contribute to a better understanding of this relationship by providing empirical outcomes.

  7. Appliances.When it involves appliances, metallic fabrication is accountable not just for the shells of stoves, dishwashers, and refrigerators but additionally for toaster enclosures, blender bases and the pressing floor of a clothes iron. Faucets.Sinks differ of their material makeup, however taps are all made from metallic. Faucets are generally made through the fabrication means of casting, as are the handles and connecting items. Locks.Of all the non-electronic features in a house or constructing of any type, door Shower Curtains for Bathroom locks contain essentially the most advanced mechanisms. The inner workings of the metallic lock are designed for an exclusive key shape, which the lock must be die cast to accommodate.

  8. This is the place you view each layer of your 3D print from the bottom, up and you'll even see the direction mittens your print head will go whereas in the printing course of. Once you’ve created a few of your individual fashions by following a tutorial, an excellent level to go to subsequent is to play around in the program and get artistic. One thing I chose to do is use quantity of} family objects and attempt to model it as finest as I might.