Using a custom and fairly lengthy CF5 form for a joomla registration (dozens of text fields, 10 plus radio buttons, checkbox, recaptcha, etc..), if the user enters an existing email address, the duplicate email warning message displays. The user is not created, but is saved to the CF5 form data datable created specifically for this form (see below.)
To prevent the public user from having to "re-type" the entire form, I dragged a Data to Session action to the processing On Submit in the Event Loop Fail box of the Joomla Reg. Action.
I also added a Data to Session in the On Load area for the second time the form is needed if there is a registration error.
When the CF5 registration form is processed using an existing email in the system (I purposely triggerred the form to error with a duplicate email message so I can test the data to session and session to data actions), the duplicate email message error appears. The data (text, radio, checkbox, recaptcha) is saved to the session. The data is also saved to a table for this CF5 registration form (e.g. cf_test_registration_form). The cf_test_registration_form table shows a user number of "0" with the text fields, checkbox, and radio button data saved.
Note that the user is not added to the user table however, because the duplicate email prevented registration. So there is no "new" user in the user table, and the user_id is "0" in the user_id field in the cf_test_registration_form.
Note that I assume the session data is pulled from a "session table" (somwhere, but not sure where it is) and not my cf_test_registration form table.
When the user reclicks on the exact same custom CF5 registration form to "correct" the error (in this case a duplicate email address, which prevents registration) , the session data (from before the error was created) pops up in the form.
Except for radio button array, as the session data does not repopulate the form for selection of the radio button before the first time the form was submitted. The text fields and check box appears fine in the session data. The session data also shows the old recaptcha confirmation numbers, which has to be deleted and re-typed with the new recaptcha confirmation numbers which show up on this "session" version of the CF5 registration form.
Is there a way to have the radio fields popoulated? I thought it might take an explode array
Several years ago, Bob previously indicated that the session to data automaticaly pulls up the data in the data array in the data, and that possibly an explode array can be used.
***********
https://www.chronoengine.com/forums/posts/f2/t22516/how-to-get-session-data.html
quote from that link
"The Data to Session action adds the stored data to the $form->data array so you should be able to use just
<?php
echo $form->data['username'];
?>"
*********
https://www.chronoengine.com/forums/posts/f2/t19693/can-not-access-form-array.html
quote from that link
"The multi-page plug-in makes the previous data available to you in an array from the user session:
<?php
if ( !$mainframe->isSite() ) { return; }
$session =& JFactory::getSession();
$posted = $session->get('chrono_formpages_data_mother_form_name', array(), md5('chrono');
?>"
***************
Back to my radio button data problem.
For logged in users, I have always exploded radio group arrays perfectly from the cf_some_form_table or from the "users" table.
Here is what works for logged in users to explode radio button arrays.
After adding getuser code, this pulls up the radio group array from a logged in user.
<?php
$user = \JFactory::getUser();
$user=JsnHelper::getUser();
$form->data[ 'radio_group_field' ] = explode(', ', $user->radio_group_field);
?>
Bingo, this always works for logged in users.
*****************
But how to get this to work for public users in the "session" trying to explode the radio button arrays?
So after getting my data for the text fields, checkbox, and recaptcha to all load from the session to the data in the "second attempt" at the registration form to fix the email address, I tried to explode my saved session data for the radio button data several ways like this:
1. custom code ON Load
<?php
$session =& JFactory::getSession();
$form->data[ 'radio_field' ] = explode(', ', $user->radio_field);
?>
2. custom code on Load
<?php
echo $form->data['radio_field'];
?>
3. handle arrays and custom code
<?php
echo $form->data['radio_field'];
?>
Nothing seems to grap the radio button data from the session data.
Any help is much appreciated.
To prevent the public user from having to "re-type" the entire form, I dragged a Data to Session action to the processing On Submit in the Event Loop Fail box of the Joomla Reg. Action.
I also added a Data to Session in the On Load area for the second time the form is needed if there is a registration error.
When the CF5 registration form is processed using an existing email in the system (I purposely triggerred the form to error with a duplicate email message so I can test the data to session and session to data actions), the duplicate email message error appears. The data (text, radio, checkbox, recaptcha) is saved to the session. The data is also saved to a table for this CF5 registration form (e.g. cf_test_registration_form). The cf_test_registration_form table shows a user number of "0" with the text fields, checkbox, and radio button data saved.
Note that the user is not added to the user table however, because the duplicate email prevented registration. So there is no "new" user in the user table, and the user_id is "0" in the user_id field in the cf_test_registration_form.
Note that I assume the session data is pulled from a "session table" (somwhere, but not sure where it is) and not my cf_test_registration form table.
When the user reclicks on the exact same custom CF5 registration form to "correct" the error (in this case a duplicate email address, which prevents registration) , the session data (from before the error was created) pops up in the form.
Except for radio button array, as the session data does not repopulate the form for selection of the radio button before the first time the form was submitted. The text fields and check box appears fine in the session data. The session data also shows the old recaptcha confirmation numbers, which has to be deleted and re-typed with the new recaptcha confirmation numbers which show up on this "session" version of the CF5 registration form.
Is there a way to have the radio fields popoulated? I thought it might take an explode array
Several years ago, Bob previously indicated that the session to data automaticaly pulls up the data in the data array in the data, and that possibly an explode array can be used.
***********
https://www.chronoengine.com/forums/posts/f2/t22516/how-to-get-session-data.html
quote from that link
"The Data to Session action adds the stored data to the $form->data array so you should be able to use just
<?php
echo $form->data['username'];
?>"
*********
https://www.chronoengine.com/forums/posts/f2/t19693/can-not-access-form-array.html
quote from that link
"The multi-page plug-in makes the previous data available to you in an array from the user session:
<?php
if ( !$mainframe->isSite() ) { return; }
$session =& JFactory::getSession();
$posted = $session->get('chrono_formpages_data_mother_form_name', array(), md5('chrono');
?>"
***************
Back to my radio button data problem.
For logged in users, I have always exploded radio group arrays perfectly from the cf_some_form_table or from the "users" table.
Here is what works for logged in users to explode radio button arrays.
After adding getuser code, this pulls up the radio group array from a logged in user.
<?php
$user = \JFactory::getUser();
$user=JsnHelper::getUser();
$form->data[ 'radio_group_field' ] = explode(', ', $user->radio_group_field);
?>
Bingo, this always works for logged in users.
*****************
But how to get this to work for public users in the "session" trying to explode the radio button arrays?
So after getting my data for the text fields, checkbox, and recaptcha to all load from the session to the data in the "second attempt" at the registration form to fix the email address, I tried to explode my saved session data for the radio button data several ways like this:
1. custom code ON Load
<?php
$session =& JFactory::getSession();
$form->data[ 'radio_field' ] = explode(', ', $user->radio_field);
?>
2. custom code on Load
<?php
echo $form->data['radio_field'];
?>
3. handle arrays and custom code
<?php
echo $form->data['radio_field'];
?>
Nothing seems to grap the radio button data from the session data.
Any help is much appreciated.
Hello,
I think this has been solved already, but just a note, what you could do is to keep the field data is an array all the time, and json encode them before saving the data then decode later after you load the data, that's the best way to handle this, and v6 makes operations like this much easier.
Best regards,
Max
I think this has been solved already, but just a note, what you could do is to keep the field data is an array all the time, and json encode them before saving the data then decode later after you load the data, that's the best way to handle this, and v6 makes operations like this much easier.
Best regards,
Max
This topic is locked and no more replies can be posted.