with this view you create an child-view to 'comercios' if it is select. Is it posible that If It havent assigned a 'comercio', the option to choose it from the view appears. (with a dropdown)
with this view you create an child-view to 'comercios' if it is select. Is it posible that If It havent assigned a 'comercio', the option to choose it from the view appears. (with a dropdown) in the custom type 'campaña_bonos' parent of coupons i have a taxiomy with 3 options, and only those businesses within that category that accept coupons should appear (accepting coupons is another taxionomy)
//AÑADIR RELATIONSHIPS PRODUCTOS
add_action( 'rest_api_init', 'create_api_posts_meta_field' );
function create_api_posts_meta_field() {
register_rest_field( 'productos', 'parent-page', array(
'get_callback' => 'get_parent_page_for_api',
'schema' => null,
)
);
}
function get_parent_page_for_api( $object ) {
//get the id of the post object array
$post_id = $object['id'];
//return the post meta
return toolset_get_related_post( $post_id, 'productos');
}
This is possible, however how i suggest doing it is to check if the post has children. Ideally you can just create a new form with just the Child Post field and just add this form to the "No Items Found" section in the child view.
So what will happen is that instead of the column displaying "No Items Found" it will display the form to assign a child post.
sorry Shane I mixed up the consultations. What I need is what I discussed in the previous post.
with this view you create an child-view to 'comercios' if it is select. Is it posible that If It havent assigned a 'comercio', the option to choose it from the view appears. (with a dropdown) in the custom type 'campaña_bonos' parent of coupons i have a taxiomy with 3 options, and only those businesses within that category that accept coupons should appear (accepting coupons is another taxionomy)
However it seems you want to filter the available coupons by taxonomies in the dropdown, which won't be possible in the post relationship for the form that you will be using.
It will instead list all the coupons and you pick one from the list.
I recommend duplicating your current edit form and adding the post relationship option field to the form then add it to the "No Items Found" section in your post.
Hello, Shane is on vacation this week so I am looking at his tickets. It sounds like you need to accomplish two things:
1. You want to display a list of the child Comercios posts for each Bonos post in the Comercios column. This seems to be working as expected, as shown in the screenshot child-comercios-list-in-results.png
2. You want a way to assign a child Comercio post to each Bonos post in the list if no child Comercios exist for that parent Bonos post.
- To do this, you must create a Relationship Form for the Bonos - Comercios relationship. That Form will allow you to select from Comercios posts and assign those to a parent Bonos post.
- You must insert the Relationship Form shortcode inside the child Comercios View in the "No results found" section of the child View's loop editor. That will display the Relationship Form only if no child Comercios exist.
- Replace the text "No results found" in the View's loop editor:
- Replace your-relationship-form-slug with the slug of the Relationship Form. You can find that in the Relationship Form editor.
- This will display a Relationship Form if no child Comercios exist for the current Bonos post. If you want to hide the parent Bonos select field, you can add custom CSS in the Relationship Form editor to hide it.
It looks like you copied the example code and pasted it in your View, but did not change the relationship form slug. That could be the problem. Did you create a Relationship Form to manage the Bonos - Comercios relationship yet? If not, that could be the problem too. You must create a Relationship Form in Toolset > Relationship Forms. Then, you must replace the example form slug in the cred-relationship-form shortcode. See my previous comment: - Replace your-relationship-form-slug with the actual slug of the Relationship Form. You can find that in the Relationship Form editor.
Perhaps you placed the Relationship Form shortcode in the Bonos View by mistake? The Relationship Form shortcode should be in the child Comercios View, because you want to display it when there are no child Comercios. Right now, I see "No items found", which indicates the Relationship Form shortcode is not in the correct location.