Hi,
I want to display a dropdown select element showing the value of last year (2015) and current year (2016). Where should I put my custom code. If I put it just before "HTML (Render Form)", it does not seem to work.
By the way, I managed to get this to show correctly, if a certain event (the value of another radio button) occurs. However, as I said above, I do NOT want it to be dependent on another event. I want these options to show when the form opens.
Following is the code, which works fine if inserted in an ajax event.
<?php
$period = date('Y'); // 2016
$periods[0] = $period - 1 ; // 2015
$periods[1] = $period ; // 2016
$membership_period = array();
$membership_period[0] = $periods[0];
$membership_period[1] = $periods[1];
echo json_encode($membership_period );
?>
Thanks for your effort and time to help...
Bilal Abdeen
I want to display a dropdown select element showing the value of last year (2015) and current year (2016). Where should I put my custom code. If I put it just before "HTML (Render Form)", it does not seem to work.
By the way, I managed to get this to show correctly, if a certain event (the value of another radio button) occurs. However, as I said above, I do NOT want it to be dependent on another event. I want these options to show when the form opens.
Following is the code, which works fine if inserted in an ajax event.
<?php
$period = date('Y'); // 2016
$periods[0] = $period - 1 ; // 2015
$periods[1] = $period ; // 2016
$membership_period = array();
$membership_period[0] = $periods[0];
$membership_period[1] = $periods[1];
echo json_encode($membership_period );
?>
Thanks for your effort and time to help...
Bilal Abdeen
First, I am sorry for the duplicate submissions. For the last few hours, almost every time I click on a topic or FAQ to open it, or try to submit a question, I get a MySQL Error, e.g. (Error displaying the error page: Application Instantiation Error: Could not connect to MySQL.)
Second, although I got the dropdown select element to show the values when an event occurs, as I mentioned above, inserting the selected value into the database did not actually work. What should be inserted is the the year value, e.g. 2015. However, what gets inserted is the index of that value, e.g. (0). It seems that I need an additional Custom Code step to convert the array index to the selected "value".
I think we need a FAQ regarding how ChronoForms handle values. I can think of at least the following scenarios, which need clarifications.
In a simple form (where there is no custom handling of values or reading from a db): (1) how and (2) when it assigns values to the ($form-data[]).
(3) when submitting values to the database, what processing takes place on the values in ($form-data[]).
(4) when the values are read from the database, what processing takes place before assigning the values to ($form-data[]).
Then, probably some suggestions on how to do similar processing (1) in case the developer needs to assign the values manually (in a custom code), (2) when the values are read from the database, and (3) before data are inserted in the db.
Thanks...
Bilal Abdeen
Second, although I got the dropdown select element to show the values when an event occurs, as I mentioned above, inserting the selected value into the database did not actually work. What should be inserted is the the year value, e.g. 2015. However, what gets inserted is the index of that value, e.g. (0). It seems that I need an additional Custom Code step to convert the array index to the selected "value".
I think we need a FAQ regarding how ChronoForms handle values. I can think of at least the following scenarios, which need clarifications.
In a simple form (where there is no custom handling of values or reading from a db): (1) how and (2) when it assigns values to the ($form-data[]).
(3) when submitting values to the database, what processing takes place on the values in ($form-data[]).
(4) when the values are read from the database, what processing takes place before assigning the values to ($form-data[]).
Then, probably some suggestions on how to do similar processing (1) in case the developer needs to assign the values manually (in a custom code), (2) when the values are read from the database, and (3) before data are inserted in the db.
Thanks...
Bilal Abdeen
Hi Bilal,
Apologies for the recurring MySQL errors on the site, hopefully Max will find a solution.
For the data questions, as I understand it:
1. 2. The data is added to the $form->data array when the event starts before any actions are run and the contents of $_POST and $_GET are added in that order which means that variables in the URL will over-write values from the form.
3. None, except quoting, they are submitted as they are.
4. None.
If you want to add or edit data use a Custom Code action to change or add values to the $form->data array.
Bob
Apologies for the recurring MySQL errors on the site, hopefully Max will find a solution.
For the data questions, as I understand it:
1. 2. The data is added to the $form->data array when the event starts before any actions are run and the contents of $_POST and $_GET are added in that order which means that variables in the URL will over-write values from the form.
3. None, except quoting, they are submitted as they are.
4. None.
If you want to add or edit data use a Custom Code action to change or add values to the $form->data array.
Bob
Thank you, Bob.
This topic is locked and no more replies can be posted.