WordPress Bricks Builder Dynamically Fill Select Options
WordPress Bricks Builder Dynamically Fill Select Options
Bricks builder for Wordpress has an option to echo a function as dynamic content for form fields.
I need to offer users a choice of dates from the next 6 days.
I have a select field and the following function:
function generate_date_options() {
$date_options = array();
// Generate dates for the next six days
for ($i = 0; $i < 6; $i++) {
$date = date('Y-m-d', strtotime("+$i days"));
$formatted_date = date('F j, Y', strtotime("+$i days"));
$date_options[$formatted_date] = $formatted_date;
}
return $date_options;
}
This function returns a list of the next 6 dates.
I want each date to be an option in the select field. But instead they are all listed on a single line separated by comas as the single select option.
The function is defined in a child theme function.php and can be called using {echo: generate_date_options()}.
The Date/Time picker would be ideal but does not allow narrowing of the range of dates available to just the next 6 days.
Any ideas on this method or an alternative gratefully received.
Turbo Multi-language Translator
Make the better internet purchasing globaly
Turbosify SEO Speed Booster
5.0 (7)•Free plan available
Get better conversions by improving store loading speed
Installed
Turbo Multi-language Chat - AI Customer service in one hand