Tell us what you are trying to do?
I am trying to populate checkbox options in the backend.
Is there any documentation that you are following?
I am using this code that I found in the support forums - which works for select options but doesn't seem to work for checkbox options.
add_filter( 'wpt_field_options', 'populate_affiliates_override', 10, 3);
function populate_affiliates_override( $options, $title, $type ){
switch( $title ){
case 'Applicable Affiliates':
$options = array();
$args = array(
'post_type' => 'partner',
'post_status' => 'publish',
'posts_per_page' => -1,
'numberposts' => -1,
'orderby' => 'title',
'order' => 'ASC'
);
$posts_array = get_posts( $args );
foreach ($posts_array as $post) {
$options[] = array(
'#value' => $post->ID,
'#title' => $post->post_title,
);
}
break;
}
return $options;
}
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Hello. Thank you for contacting the Toolset support.
Checkboxes are a quite special field type that stores its value as serialized array in to the database.
There is no such way to dynamically populate the checkboxes fields.
Hmmm. So it is only possible to populate them on the front end then?
https://toolset.com/forums/topic/auto-populate-checkboxes-field-with-custom-post-type-title/
If it is not possible to populate them on the backend, is there a different field we can dynamically populate that allows more than 1 selection?
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Yes - that's different thing and its using Toolset form using Generic field.
Unfortunately there is no way to auto-populate the checkboxes field in the backend.
If it is not possible to populate them on the backend, is there a different field we can dynamically populate that allows more than 1 selection?
==>
What if you create a many-to-many post relationship or one to many post relationship which suites your need, will that work?