How to add some php code ?

Hello everyone,

I'm a beginner in Concrete 5 and till now, I have only added HTML code (Add block -> Content) but now I need to add some php code in a block and I know it's impossible to add directly...
Actually, I want to execute the php code after submiting a form.
Can anyone explain it to me ?

Thank you in advance !

View Replies:
ronyDdeveloper replied on at Permalink Reply
You can add php code through this add-on

bryan63 replied on at Permalink Reply
Okay, I will check this.
Thank you !
JohntheFish replied on at Permalink Reply
To execute code after submitting a form, you will need to override the form block controller and add your code to the action (function) that handles the submit.

There was some discussion in the past of an on_form_submit event being added (I don't know if it has been). If so, you task is made easier because you can simply add an event handler rather than needing to override the controller file.

You may find that one of the more specialised form block addons already has such an event or another means of adding your code to the form submission.
bryan63 replied on at Permalink Reply
Actually, I just need to send an email with an attached file (the user leave his email address in the form and receive the file after submitting the form). I know how to do without Concrete 5 but I have no idea with Concrete 5.

Of course, the email address is saved in the database.
JohntheFish replied on at Permalink Reply
If you look at the 'Contact Us' form provided in the default content when concrete5 is installed, that is set up to send you an email when a visitor completes the form.

So most of what you want is in the block. What you would need to do in a block controller override is to change it to send an email to the visitor(easy) and to attach the file to it(maybe a bit more difficult).

However, stuff like that is such a common requirement that I suspect one of the advanced form addons may already do it for you and for the cost of a few tens of $ would usually be good value compared to the time it would take you to code the override.

There are also addons for membership and for adding digital docs to eCommerce that do this sort of thing (though are obviously more expensive than a clever form addon)
bryan63 replied on at Permalink Reply
Well, okay thank you.
Will think about it !