Forminator date range selection
-
Hi,
i’m facing to a problem using a Forminator form (rev 1.31.0) on wordpress rev 6.5.5
The form created is about two range of date of birth :
The date format is set to : d/m/y
The form is using two range of date of birth : the “RANGE1” is between 10/10/1939 and 27/04/1941 ( included) , and the “RANGE2” is between 22/03/1938 and 09/10/1939 ( included)
I have created two behavior in this form , so when the operator set a birth date within the RANGE1, the submit goes to RANGE1 page , and when when the operator set a birth date within the RANGE2, the submit goes to RANGE2 page.
My problem is when i set the date to 10/10/1939 , the submit goes to the “RANGE2” page instead of “RANGE1” page
Can-you help me if my form program is wrong or something else ?
Please look at my form exported named “Forminator_Test dates de naissances.txt”
Thanks by advance
BR Dominique
-
Hi ,
i have another problem with my data range form : with two range it’s running fine, but when i add a “range3” , this range is not working : for example when i select the date 2 september 1936 , it goes on range2 instead of range3 ( in fact if i select the date into data range3 , it goes on data range2
Please look at my form here : https://drive.google.com/file/d/1lE-V0ygvxku8fqrxRKkSZkkKMxdgn37g/view?usp=sharing
for information i put the three ranges :
from [10/10/39 to 27/4/41] : range1
from [22/3/38 to 9/10/39] : range2
from [2/9/36 to 21/3/38] : range3
you can check it on my site : https://astro-dom.ovh
BR
Dominique
PS: for information, i need to add up to 12 ranges on my site.
-
This reply was modified 3 months, 3 weeks ago by
dba83.
Hi @dba83
I pinged our SLS Team once more to see what we can do in that matter. We will post an update here as soon as more information is available.
Kind Regards,
KrisHi @dba83,
We have identified the issue is because of a bug at the Formianrot end. Can you please try if the following workaround helps?
add_action( 'forminator_form_before_handle_submit', 'wpmudev_date_condition_fix', 10, 1 ); add_action( 'forminator_form_before_save_entry', 'wpmudev_date_condition_fix', 10, 1 ); function wpmudev_date_condition_fix( $form_id ) { if ( 46150 !== intval( $form_id ) ) { // Please change the form ID. return; } if ( ! empty( Forminator_CForm_Front_Action::$prepared_data['date-1'] ) ) { Forminator_CForm_Front_Action::$prepared_data['date-1'] = str_replace( '/', '-', Forminator_CForm_Front_Action::$prepared_data['date-1'] ); Forminator_CForm_Front_Action::$prepared_data['date-1'] = date_i18n( 'd/m/Y', ( strtotime( '-1 day', strtotime( Forminator_CForm_Front_Action::$prepared_data['date-1'] ) ) ) ); } }
Please note, 46150 in the above code should be changed to your form’s ID. You can add the code using a mu-plugin: https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins
Please test the code on a development/staging environment before implementing it on the live website.
I hope that helps.
Kind Regards,
Nebu JohnHi John,
thanks for your reply, but i am not aware about how to install this Php code, what are “mu-plugins” ?
when i try to install “mu-plugins” extension on wordpress i can’t find it..
Can-you please help me to install your Php code ?
BR
Dominique
Hi @dba83,
Did you check the documentation regarding creating mu-plugins as mentioned below, it does explain your query:
https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins
ie these are the steps:
Create an?mu-plugins?directory (folder) in the?wp-content?directory
Create an mu-plugin php file
Upload/install that file on a site via FTP
The given snippet needs to be added as a PHP file inside the mu-plugins directory. You’ll need to use SFTP, File Manager etc to access the server to make the changes.
Does the above steps helps?
You can also refer the following too:
https://wp-staging.com/how-to-make-a-wordpress-mu-plugin/Kind Regards,
Nithin
Hi Nithin,
Thanks , i have done the update : i had access to my site by using “Filezilla”, then created the directory “mu-plugin” under directory “wp-contents” , then uploaded the file “code1.php” which include your php code ( i have modifyed the form ID with mine)
When i go to my site, i see the must-use plugin activated , but the form is not working any more
ant i have always your code on the top of each page ( go to my site : https://astro-dom.ovh/ )
If i add the line <?php at the beginning of the file , my site is crashing
BR
Dominique
Hi @dba83
I hope you are doing well.
We need to have the <?php otherwise the code won’t work.
I tested the code:
<?php add_action( 'forminator_form_before_handle_submit', 'wpmudev_date_condition_fix', 10, 1 ); add_action( 'forminator_form_before_save_entry', 'wpmudev_date_condition_fix', 10, 1 ); function wpmudev_date_condition_fix( $form_id ) { if ( 46150 !== intval( $form_id ) ) { // Please change the form ID. return; } if ( ! empty( Forminator_CForm_Front_Action::$prepared_data['date-1'] ) ) { Forminator_CForm_Front_Action::$prepared_data['date-1'] = str_replace( '/', '-', Forminator_CForm_Front_Action::$prepared_data['date-1'] ); Forminator_CForm_Front_Action::$prepared_data['date-1'] = date_i18n( 'd/m/Y', ( strtotime( '-1 day', strtotime( Forminator_CForm_Front_Action::$prepared_data['date-1'] ) ) ) ); } }
But didn’t have any errors.
Can you try again, in case it breaks please enable the debug mode: https://wpmudev.com/blog/debugging-wordpress-how-to-use-wp_debug/ to check the debug.log file and see why the error is happening.
Let us know the result you got.
Best Regards
Patrick FreitasHi Patrick,
sorry but it’s don’t work in my side. I have activated the debug mode and the error is :
“Parse error: syntax error, unexpected token “&” in /home/astrodf/www/wp-content/mu-plugins/code_php.php on line 3
There has been a critical error on this website.“
Please find below the link to view your script code “code_php.php” ,the error displayed when i try to access to my site , and also the screenshot of the wp-contents directory using filezilla
https://drive.google.com/drive/folders/1NWukzoSQ4RRFsZd_N8e2IfbHlRE-yBd7?usp=sharing
Thanks by advance
BR
Dominique
Hello @dba83,
I’ve noticed that in your current PHP file all single quotes are replaced with the corresponding HTML entities, that’s why the code can’t be executed:
https://prnt.sc/-AvqtyKHB4aTCould you please try copying the code again, and pasting it into a different text editor, and make sure it doesn’t substitute any symbols.
As an alternative, I’ve also shared it via Pastebin.com, here’s the link:
https://pastebin.com/uFj40hN6– you can click “download” to download the code as is in a TXT file:
https://prnt.sc/E3UZd__BlqN8I hope that helps. Let us know if you need further assistance!
Best Regards,
Dmytro-
This reply was modified 3 months, 2 weeks ago by
Dmytro - WPMU DEV Support.
Hi Dmytro,
sorry i should have seen it ! , i have modified the Php file as you indicated (“__php.php”) , but unfortunately the form is not working : when i select the date 2 september 1936 , the submit is range 2 instead of range 3.
i have tested an inside date of range 3 ( ie 10 september 1937) : same result : range 2
please look at the results : https://drive.google.com/drive/folders/1NWukzoSQ4RRFsZd_N8e2IfbHlRE-yBd7?usp=sharing
BR
Dominique
Hi @dba83,
Hope this message finds you well.
when i select the date 2 september 1936 , the submit is range 2 instead of range 3.
Sorry, but it sounds a little confusing, I imported your form and I can confirm Range 3 is set for that range of dates so it is the expected behavior:
Same as on your screenshot:
Also for 10/09/1937:
Let us know if you require additional assistance.
Best regards,
LauraHi Laura,
sorry but the dates you indicate are not my form dates (I don’t think I explained very well this point) , to be clearer, you will find the three form range on my link below : https://drive.google.com/drive/folders/1NWukzoSQ4RRFsZd_N8e2IfbHlRE-yBd7?usp=sharing
i confirm-you that when i select the date 2 september 1936 its link to range 2 instead of range 3
however , before submission the range3 is correctly displayed ( see the screenshot “2 september 1936.jpg” on my drive space )
This is the same behavior within the range3 date range ( its link to range2)
here my site : https://astro-dom.ovh/
BR
Dominique
Hi @dba83,
Thanks for sharing the information.
It seems you performed some updates to the Ragnes since they are different from the form you shared in your Google Drive.
To get things clear let me break down the recent changes here:
Range 1 is 10/09/1939 – 04/28/1941
Range 2 is 03/21/1938 – 10/09/1939
Range 3 is 09/01/1936 – 03/22/1938Still, I am not able to reproduce the issue, when I select 02/09/1936 (note that I am using dd/mm/YYYY) format, I get the Range03 in submission as in the form:
Something that caught my attention is in your screenshots dates detailed above, they seem to be using a mixed format mm/dd/YYYY.
Could you please double-check the date format you are using for the dates?
Let us know.
Best regards,
LauraThanks Laura for your quick reply,
i pay attention about the data format : as you , i have selected the format d/m/Y ( it is correctly set on “Entrez votre date de naissance‘ field) , but on each visibility range field, when i select a date ,i see that it is always programmed with the m/d/Y format …
For information, i have check the settings of the wordpress engine, and from the beginning the date was set to m/d/Y format, so i have updated this setting according to the “Entrez votre date de naissance‘ field form and now the wordpress format is : d/m/Y
However, even if i re-create the form, on each visibility range field, when i select a date , it is always programmed with the m/d/Y format , i don’t know why ? probably i need to flush the wordpress cache or re-install the forminator plugin ?
look at my screenshots : https://drive.google.com/drive/folders/1NWukzoSQ4RRFsZd_N8e2IfbHlRE-yBd7?usp=sharing
BR
Dominique
H i@dba83,
Sorry if I’m repeating myself, however, is the issue only with the m/d/Y format showing up while setting up the Visibility Condition? or are you facing issues while submitting the form?
The m/d/Y format noticed is the expected behaviour during the visibility condition, are you facing any issues due to that with setting up the form? If yes, possible to explain a bit more regarding the issues noticed so that we could have a better idea?
Kind Regards,
Nithin
-
This reply was modified 3 months, 3 weeks ago by
- You must be logged in to reply to this topic.