I too couldn’t believe that after nearly a year that this is still not supported. It’s such a big oversight.
Anyway, in his example pre_render hook example, which is simplified:
if ( GFCommon::is_form_editor() || $YOUR_FORM_THAT_YOURE_TARGETTING != $form['id'] ) {
return $form;
}
if ( is_array( $form ) || is_object( $form ) ) {
foreach ( $form['fields'] as &$field ) { // for all form fields
$field_id = $field['id'];
if ( YOUR_FIELD_ID_THAT_YOURE_TARGETTING != $field_id ) {
break;
}
if ( 'list' == $field->get_input_type() ) {
$has_columns = is_array( $field->choices );
if ( $has_columns ) {
$array = [];
foreach ( $field->choices as $key => &$choice ) { // for each column
$isDropDown = rgar( $choice, 'isDropDown' );
if ( $isDropDown ) {
// basically, this is where the magic has to happen. Build up your array with value and text options and then finally append it onto $choice['isDropDownChoices'].
$array[] =['value' => 0, 'text' => 'first choice'];
$array[] =['value' => 10, 'text' => 'second choice'];
$array[] =['value' => 20, 'text' => 'third choice'];
$choice['isDropDownChoices'] = $array;
}
}
}
}
}
}
return $form;
-
This reply was modified 6 years, 1 month ago by proximity2008. Reason: explanations
-
This reply was modified 6 years, 1 month ago by proximity2008.
-
This reply was modified 6 years, 1 month ago by proximity2008.