Month dropdown Pre_render

Hi and thanks for your assistance in advance.

I have a month dropdown that users can select from which is passed on via the URL. The challenge I face is that if the user selects November I want to ensure it passes the year for the next November if the current one has passed.

I cannot see a way of doing this with the inbuilt gravity forms so I assume that the only way this can happen is to use Pre_render on a dropdown.

I have some experience in PHP and have managed to develop the following code, however I am stuck as to how this gets turned into a webhook for Gravity Forms.

<?php
$no_of_iterations = 11;
$time = strtotime(date('Y-m-d'));
echo  "<select name='date' id='date'>";
for($i = 0; $i <= $no_of_iterations; $i++) {
     $date_in = date("Y-m-d", strtotime("+$i month", $time));
    echo "<option value='".date("m/Y", strtotime($date_in))."'>".date("F", strtotime($date_in))."</option>";
}
echo "</select>";

If the forms is ID:1 and the field is ID:5 can anyone please assist with creating a webhook for this?

Thanks again
zero

Rather than using gform_pre_render to set a value here, check out the filter gform_field_value_$parameter_name. For additional usage notes on that, you can reference the hook section of the article Dynamically Populating a Field.

Thanks Joshua for pointing me in the right direction.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.