Skip Navigation

[Resolved] Radio type options not showing in custom fields

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 7 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 4 replies, has 2 voices.

Last updated by dirkM-4 7 years, 5 months ago.

Assisted by: Shane.

Author
Posts
#538628

I am trying to: propose radio type custom field in a custom field group.

I visited this URL:

I expected to see: to see the radio options to select

Instead, I got: only the title of the custom field group and no radio buttons to click.

I found a workaround in changing the source code at types/library/toolset/toolset-common/toolset-forms/classes/class.radios.php on line 81 from

$options = apply_filters( 'wpt_field_options', $options, $title, 'select' );

to

$options = apply_filters( 'wpt_field_options', $options, $title, 'radios' );

Is there another way to avoid the changes in the source code?

Thanks in advance.

#538756

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Dirk,

Thank you for contacting our support forum.

Would you mind providing me with a screenshot of the issue so that I can have a look at the issue?

Thanks,
Shane

#538995
Edit_product_with_workaround.jpg
Edit_product_original.jpg
Edit_with_workaround.jpg
Edit_original.jpg

Hey Shane,
thanks for your reply. I will provide 4 screenshots. 2 called "originals" showing the result without the workaround, missing the radio buttons under the custom field group title. The other 2 "with_workaround" showing the clickable options of the radio field as well.

Thanks again.

#539134

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Dirk,

Thank you for the screenshots.

However i'm not able to replicate the problem on a fresh install using our latest types plugins.

Are you currently running Types version 2.2.13?

Please let me know.

Thanks,
Shane

#539161

Hey Shane,

thanks! This is good to know and brought me to an explication. I used the filter hook "wpt_field_options" to populate select fields with values from another CPT. Like this:

//### Populate Types select field with another CPT ###*/
function add_some_options($options, $title, $type) {

            if ($type == 'select'){
                $options = array();
            // Add Promt Text
            $prompt_from[] = array(
                '#value' => 0,
                '#title' => 'Sélectionnez le père'
            );
            $prompt_to[] = array(
                '#value' => 0,
                '#title' => 'Sélectionnez la mère'
            );
 
            // Counter
            $i = 1;
 
            // The Père Query
            $pere_args = array (
                'post_type' => 'notre-chien',
                'tax_query' => array(
                    array(
                        'taxonomy' => 'categorie-chien',
                        'field'    => 'id',
                        'terms'    => 18,
                    ),
                ),
                'orderby' => 'menu_order',
                'order'   => 'ASC',
                'posts_per_page' => -1,
 
            );
            $peres = get_posts( $pere_args );
 
            // Peres Loop
            foreach ($peres as $pere) {
 
                $pere_options[] = array(
                '#value' => $pere->ID,
                '#title' => $pere->post_title
                );
            }
 
            // Blank Option to Seperate
            $blank[] = array(
                '#value' => -1,
                '#title' => ''
            );
 
            // The Mère Query
            $mere_args = array (
                'post_type' => 'notre-chien',
                'tax_query' => array(
                    array(
                        'taxonomy' => 'categorie-chien',
                        'field'    => 'id',
                        'terms'    => 20,
                    ),
                ),
                'orderby' => 'menu_order',
                'order'   => 'ASC',
                'posts_per_page' => -1,
 
            );
            $meres = get_posts( $mere_args );
            
            // The  Loop
            foreach ($meres as $mere) {
 
                $mere_options[] = array(
                '#value' => $mere->ID,
                '#title' => $mere->post_title
                );
            }
 
           // Assign To The Select Fields
            switch( $title ) {
                case 'Père':
                    $options = array_merge(
                        $prompt_from,
                        $pere_options
                        
                    );
                break;
 
                case 'Mère':
                    $options = array_merge(
                        $prompt_to,
                        $mere_options
                       
                    );
                break;
            }
            }
            return $options;
            wp_reset_postdata();
    }
add_filter( 'wpt_field_options', 'add_some_options', 10, 3);

As the $type argument in the "apply_filters" is set to "select" in class.radios.php and class.select.php I got this result with the radio fields. I am really sorry to have overseen this.

I read another thread in the forum which said that this filter hook works for select and radio fields (https://toolset.com/forums/topic/wpt_field_options-multiple-select/), therefore I haven't hesitated to use it as I did.

Actually I use Types version 2.2.13.

Thanks a lot!

The forum ‘Types Community Support’ is closed to new topics and replies.