![](https://secure.gravatar.com/avatar/f3c36bb8920f6b75cd720f131c6a9065?s=80&d=mm&r=g)
Shane
Supporter
Idiomas:
Inglés (English )
Zona horaria:
America/Jamaica (GMT-05:00)
Hello,
Structure it like this.
[wpv-conditional if="( $(wpcf-comprobante) eq '' )"]
[cred_form form="adjunto-bonos"]
[/wpv-conditional]
[wpv-conditional if="( $(wpcf-comprobante) ne '' )"]
[types field='comprobante'][/types]
[/wpv-conditional]
Please let me know if this helps.
Thanks,
Shane
thank you shane,
but I put that in place of something?
because if I put it like that, it doesn't work
<td>[types field='nombre_campana' separator=', ' item='@campana-bonos-bono.parent'][/types]</td>
<td>[types field="referencia-del-bono"][/types]</td>
<td>[types field="fecha-de-creacion-del-bono"][/types]</td>
<td>[wpv-post-taxonomy type="estado"]</td>
<td>[types field='comprobante'][/types][cred_form form="adjunto-bonos"]</td>
<td>[wpv-view name="child-view"]</td>
[wpv-conditional if="( $(wpcf-comprobante) eq '' )"]
[cred_form form="adjunto-bonos"]
[/wpv-conditional]
[wpv-conditional if="( $(wpcf-comprobante) ne '' )"]
[types field='comprobante'][/types]
[/wpv-conditional]
![](https://secure.gravatar.com/avatar/f3c36bb8920f6b75cd720f131c6a9065?s=80&d=mm&r=g)
Shane
Supporter
Idiomas:
Inglés (English )
Zona horaria:
America/Jamaica (GMT-05:00)
Hello,
I've added it to the correct place now.
It should be like this.
<td>[types field='nombre_campana' separator=', ' item='@campana-bonos-bono.parent'][/types]</td>
<td>[types field="referencia-del-bono"][/types]</td>
<td>[types field="fecha-de-creacion-del-bono"][/types]</td>
<td>[wpv-post-taxonomy type="estado"]</td>
<td>
[wpv-conditional if="( $(wpcf-comprobante) eq '' )"]
[cred_form form="adjunto-bonos"]
[/wpv-conditional]
[wpv-conditional if="( $(wpcf-comprobante) ne '' )"]
[types field='comprobante'][/types]
[/wpv-conditional]</td>
<td>[wpv-view name="child-view"]</td>
Thanks,
Shane
Hi Shane,
I have only one question.
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)
Hi Shane,
I have only one question.
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)
I've set it up just like this one does:
//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');
}
That's why I don't know what I'm doing wrong
![](https://secure.gravatar.com/avatar/f3c36bb8920f6b75cd720f131c6a9065?s=80&d=mm&r=g)
Shane
Supporter
Idiomas:
Inglés (English )
Zona horaria:
America/Jamaica (GMT-05:00)
Hello,
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.
Please let me know if this helps.
Thanks,
Shane
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)
![](https://secure.gravatar.com/avatar/f3c36bb8920f6b75cd720f131c6a9065?s=80&d=mm&r=g)
Shane
Supporter
Idiomas:
Inglés (English )
Zona horaria:
America/Jamaica (GMT-05:00)
Hello,
I actually explained how to achieve this here.
https://toolset.com/forums/topic/view-with-relationship/page/2/#post-1859297
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.
Thanks,
Shane
I think the problem is that I don't know how to use the child-view, could you give me an example?
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:
[wpv-no-items-found]No results found[/wpv-no-items-found]
- Insert the Relationship Form shortcode instead of "No results found" text, like this:
[wpv-no-items-found][cred-relationship-form form='your-relationship-form-slug' parent_item='$current'][/wpv-no-items-found]
- 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.
HI Christian,
I replace with this, (last two lines) but doesnt work it.
[wpv-layout-start]
[wpv-items-found]
<!-- wpv-loop-start -->
<table width="100%">
<thead>
<tr>
<th>[wpv-heading name="types-field-nombre_campana"]Nombre de la campaña[/wpv-heading]</th>
<th>[wpv-heading name="types-field-referencia-del-bono"]Referencia del bono[/wpv-heading]</th>
<th>[wpv-heading name="types-field-fecha-de-creacion-del-bono"]Fecha de creación del bono[/wpv-heading]</th>
<th>[wpv-heading name="post-taxonomy"]Estados[/wpv-heading]</th>
<th>[types field='comprobante'][/types]</th>
<th>[wpv-heading name="post-taxonomy"]Comercios[/wpv-heading]</th>
</tr>
</thead>
<tbody class="wpv-loop js-wpv-loop">
<wpv-loop>
<tr>
[wpv-post-body view_template="loop-item-in-listado-bonos-administrador"]
</tr>
</wpv-loop>
</tbody>
</table>
<!-- wpv-loop-end -->
[/wpv-items-found]
[wpv-no-items-found][cred-relationship-form form='your-relationship-form-slug' parent_item='$current'][/wpv-no-items-found]
[wpv-layout-end]
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.