I used for many years CF5 and CC5 for some complex forms. Now I am trying to migrate to CF8.
What I am missing is the event loop function and if fields groups can be made conditional.
CF8 seems to me to be the best version since CF5, but still missing comprehensive manuals or instructions.
Is there hope to see them in the near future?
Thanks Max for the support
What I am missing is the event loop function and if fields groups can be made conditional.
CF8 seems to me to be the best version since CF5, but still missing comprehensive manuals or instructions.
Is there hope to see them in the near future?
Thanks Max for the support
I am also missing the event loop function.
Max is looking into it.
I will post the solution here for you.
Max is looking into it.
I will post the solution here for you.
you can have an event loop in cf8 if you add a PHP action and register an error:
if you add this in the "submit" event of any page then it will repeat the last step
$this->errors["whatever"] = "error message";
if you add this in the "submit" event of any page then it will repeat the last step
It's sound perfect, but this is magic for me, and I don't understand how to use it.
I sent you a email.
Thank you very much
I sent you a email.
Thank you very much
Dear kraadde,
Could you please tell me if you managed to reproduce the Event Loop of V5 with the V8 as advised by Max?
I do not know how to do it.
Thank you very much
Sylvain
Could you please tell me if you managed to reproduce the Event Loop of V5 with the V8 as advised by Max?
I do not know how to do it.
Thank you very much
Sylvain
Sorry, but I did not manage to reproduce . I think that Max should try to add this feature as it was with V5 asap.
I asked Chat GPT, how to use :
And it answer is:
But I didn't find how to use it.
Can it help you?
$this->errors["whatever"] = "error message";
And it answer is:
<?php
class MyForm {
public $errors = array();
public function submit() {
// Some form processing code here...
// If there is an error, register it
if (/* some condition */) {
$this->errors["whatever"] = "error message";
}
// If there are any errors, repeat the last step
if (!empty($this->errors)) {
$this->repeatLastStep();
}
}
public function repeatLastStep() {
// Code to repeat the last step...
}
}
$form = new MyForm();
$form->submit();
?>
But I didn't find how to use it.
Can it help you?
ChatGPT is hallucinating here, just add that code in a PHP action in the "submit" event of your form page, replace "whatever" with the field name in your form, like "name" or "age" and that will redisplay the page and show an error
I also need this feature in CF8. I manage to get an error message shown using something like:
$this->errors["sur_name"] = "wrong surname";
whowever the submit routine also continues and shows the success message, whereas the error message is not shown in the context of the HTML form in the Load section.
Is it possible to cancel everything in the Submit section that comes after the PHP action setting the error? And then show the error message(s) in the context of the HTML form?
P.S. In the Load section I use custom HTML as form (don't know if that makes a difference).
Edit: Actually I got it to work in CF8 by deriving from this FAQ entry for CF6: https://www.chronoengine.com/faqs/chronoforms/chronoforms6/validating-fields (paragraph "2 - Custom PHP validation function ")
$this->errors["sur_name"] = "wrong surname";
whowever the submit routine also continues and shows the success message, whereas the error message is not shown in the context of the HTML form in the Load section.
Is it possible to cancel everything in the Submit section that comes after the PHP action setting the error? And then show the error message(s) in the context of the HTML form?
P.S. In the Load section I use custom HTML as form (don't know if that makes a difference).
Edit: Actually I got it to work in CF8 by deriving from this FAQ entry for CF6: https://www.chronoengine.com/faqs/chronoforms/chronoforms6/validating-fields (paragraph "2 - Custom PHP validation function ")
Dear kraadde,
Could you please send me the working PHP code?
I am stuck at the php
Thank you very much !
Sylvain
Could you please send me the working PHP code?
I am stuck at the php
Thank you very much !
Sylvain
Hi Sylvain,
Example php-code (e.g. if you have an input textfield called "surname" for which you wish to configure server side validation):
In this case since true/false are the possible return values, these are configured as events. For each event actions are then specified within each event block (see attached screenshot). In my situation I've configured the "false" section end-user-unfriendly on purpose, because normal users would normally not get there, only those that have disabled javascript (e.g. those that purposely attempt to bypass client-side validation).
I don't know if this is the best way to approach it, but missing documentation myself, this is how I managed to get it to work in a way that serves my purpose.
Example php-code (e.g. if you have an input textfield called "surname" for which you wish to configure server side validation):
if (!isset($this->data['surname']) || trim($this->data['surname']) == '') {
$this->errors["surname"] = "Please enter a surname!";
return false;
} else {
return true;
}
In this case since true/false are the possible return values, these are configured as events. For each event actions are then specified within each event block (see attached screenshot). In my situation I've configured the "false" section end-user-unfriendly on purpose, because normal users would normally not get there, only those that have disabled javascript (e.g. those that purposely attempt to bypass client-side validation).
I don't know if this is the best way to approach it, but missing documentation myself, this is how I managed to get it to work in a way that serves my purpose.

Server side validation example
Dear,
I am very sorry, but how to you NOT display the error message?
I would be happy if the page keep on looping, but without the error message.
Thank you very much,
Sylvain
I am very sorry, but how to you NOT display the error message?
I would be happy if the page keep on looping, but without the error message.
Thank you very much,
Sylvain
You need to login to be able to post a reply.