Functions not found in CF8

kraadde 19 Jan, 2024
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
certi 22 Jan, 2024
I am also missing the event loop function.

Max is looking into it.
I will post the solution here for you.
Max_admin 24 Jan, 2024
you can have an event loop in cf8 if you add a PHP action and register an error:

$this->errors["whatever"] = "error message";


if you add this in the "submit" event of any page then it will repeat the last step
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
certi 24 Jan, 2024
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
certi 29 Jan, 2024
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
kraadde 29 Jan, 2024
Sorry, but I did not manage to reproduce . I think that Max should try to add this feature as it was with V5 asap.
certi 22 Feb, 2024
I asked Chat GPT, how to use :
$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?
Max_admin 23 Feb, 2024
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
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
mart1jn 24 Feb, 2024
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 ")
certi 29 Feb, 2024
Dear kraadde,

Could you please send me the working PHP code?
I am stuck at the php

Thank you very much !

Sylvain
mart1jn 02 Mar, 2024
2 Likes
Hi Sylvain,

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.
serverside_validation.png

Server side validation example

certi 13 Mar, 2024
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
certi 13 Mar, 2024
Sorry again.

I found how to remove the message... but how does this make the page looping?

Please Max, could you please just make me pay and do it for me!
Its already 3 months my website doesnt show prices to my costumer because of this issue.

Thank you for your help.

Sylvain
You need to login to be able to post a reply.

VPS & Email Hosting 20% discount
hostinger