Creating a custon form

Permalink
So I added a custom form as an HTML block, but what should I put as the action url in it? Do I need to create a new file or a new page in Concrete5 to handle the request?

 
jordanlev replied on at Permalink Reply
jordanlev
There are a few different approaches to take here but it sounds like the best solution for your situation would be to use the "External Form" block. Check out YOURSITE/concrete/blocks/external_form/forms/ for an example of how it works. To add your own, copy that "forms" directory to:
YOURSITE/blocks/external_form/

(so you're copying it to OUTSIDE of the /concrete/ directory)
Then change the name of the test_form.php file in that folder AND in the "controllers" subfolder to something else (should be the same for both of those files, but different from "test_form"). Now you can modify that to your liking.

When you're done you can add the form to a page by adding the "External Form" block and choosing the form you made from the list.

-Jordan
Webaholic replied on at Permalink Reply
Thanks Jordan,

I actually thought of a solution just after I posted this, I just simply pointed the action field to the current page where the form is and created the validation in the theme file for that page.
grorog replied on at Permalink Reply
Hello!
I have two things which are not clear to me: the action of the form, and how to validate fields..
How can I create required fields for example?
jordanlev replied on at Permalink Reply
jordanlev
It's been a while since I wrote this response, and since then I've actually changed my mind about the external_form block -- it has a number of annoying limitations and quirks which make it very difficult to use a lot of the time (in my experience anyway).

What I do instead now is just create a block that has a form in it. I've put up a simple example of a contact form block, which shows things like how to handle the action of the form, and how to validate fields. The code is available here:

https://github.com/jordanlev/c5_custom_contact_form...