Gravity Forms fill Custom Fields in Radio Button (AFC)

 

[php]

//Populate Gravity Form with
add_filter( ‚gform_pre_render_16‘, ‚bflow_populate_event_dates‘ );

function bflow_populate_event_dates( $form ) {

global $post;

// Add Custom Post Field Dates in array
$dates = array();
for ($i = 0; $i < 3; $i++ ) { $field_name = 'termin_' . $i; $dates[$i] = get_field($field_name); } //Creating item array. $items = array(); foreach ( $dates as $date ) { $items[] = array( 'value' => $date, ‚text‘ => $date );
}

//Adding items to field id 5.
foreach ( $form[‚fields‘] as &$field ) {
if ( $field->id == 5 ) {
$field->choices = $items;
}
}

return $form;
}

[/php]

War dieser Artikel hilfreich?
Nach oben scrollen