External form or hard coded form block?
I need to include a form in a page type, which has the some basic functionality as the c5 form block: it can send email messages when the form is submitted and the submissions are tracked in the C5 report system. The email messages must have a subject that is different, depending on the page the form was submitted from. I have no clue on how to start implementing such forms. I would be very happy if someone could give me some help on this. Thanks!
Of course you need to modify this code to what you need. But the idea is simple, just switch through the form name and act accordingly.
Not exactly the MOST elegant way but works pretty well for me ;)
Thank you for your efforts! Unfortunatelly, this is exactly what I want to bypass, because there are at least 30 pages plus translations in three languages. :/
I started studying the form controller, specifically the action_form_submit (or something like that) method and I noticed, that might be code I need to copy and modify to suit my needs, but I am somewhat overwhelmed by it -- it seems way too much for such an easy task. :(
...One my favourites
1. Unzip and move the "custom_contact_form" folder to your site's top-level "blocks" directory (note: this is just a block, *not* a package -- so don't put it in your "packages" directory).
2. Rename the "custom_contact_form" folder as desired (should be the lowercase_and_underscore version of your block's name -- for example, "My Great Form" would get a directory name of "my_great_form").
3. Edit the block's "controller.php" file:
* Change the class name to be a TitleCaseWithNoSpaces version of the block name (otherwise known as CamelCase), followed by "BlockController" -- for example, "My Great Form" would get a class name of "MyGreatFormBlockController".
* Change the block name and description. It is recommended that the name correspond with the directory and class names, but this is not a technical requirement (just avoids confusion).
* Change the table name to "bt" followed by the CamelCase version of the block name -- for example, "My Great Form" would get a table name of "btMyGreatForm".
4. Edit "db.xml" file so the table name matches what you set in "controller.php".
5. Customize the form as needed. The view.php file contains the form html. The action_submit_form() method in controller.php responds to form submissions.
I'll give some feedback, when I gave it a try. This task is currently paused. But thanks for the help, nevertheless!
Stumbled upon your solution by luck. Seemed like an easy method to hardcode a custom form. Followed your instructions and had a custom form in seconds.
Unfortunately, nothing happens on submit? =(
Only things I've changed are the block names, as instructed and changed the input fields in view.php. In the Dashboard > Reports > Form Results, the new Custom Form is visible, but the # of submissions stays 0. Guess the form is just being cocky and doesn't wants to cooperate =P
PS: when I inspect the form, the action attr. is empty?
Hope that helps!
EDIT: Oops, forgot the link:https://github.com/jordanlev/c5_custom_contact_form...
Works awesome, thnx for sharing ;)