Skip Navigation

[Resuelto] RelationShip required

This support ticket is created hace 5 años, 3 meses. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

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

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

Este tema contiene 10 respuestas, tiene 2 mensajes.

Última actualización por Francisco Ramón Molina Busquiel hace 5 años, 3 meses.

Asistido por: Luo Yang.

Autor
Mensajes
#1310601

Hi,

A field can be set as required, but a relationship between types how can it be set as required for input in dashboard?
For example, I have 1 relationship between the "Manufacturers" type and the "Printers" type, when I add a printer I would like it to be mandatory to indicate a manufacturer.

Note: I put this request in the section of Toolset non-existent necessary features, but Minesh told me in an email that I should put it in the forum.

Thanks.
Regards,
Francisco R.

#1310821

Dear Francisco,

I assume you are going to setup one-to-many relationship between post type "Manufacturers" and "Printers".
In your case, you can consider the custom "Post Reference" field, it is also based on one-to-many post type relationship.
For example, Dashboard-> Toolset-> Custom Fields, add a custom field group for post type "Printers".

Click button "Add New Field", you should be able to see an option "Post Reference", you can also use "Required" validation in it, see screenshot:
enlace oculto

More help:
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/using-post-reference-fields-to-display-information-from-a-related-post/

#1310865

Dear Luo,

Yes. The "post reference" field is very interesting and can be used for what you wanted.
With the "Relationships" feature of Toolset I was taking all printers related to a manufacturer as follows:

	$impresoras = toolset_get_related_posts(
  		$manufacturer, // <<<<<<<<<<<<<<<<<
  		'fabricante-impresora', // relationship between the posts
  		'parent', // get posts where product is the child in given relationship
  		10, 0, // pagination
  		array(), // no extra args needed here
  		'post_object', // return post objects
  		'child' // return the related parent post(s) in this relationship
	);
	foreach ($impresoras as $post_i) {
		$result[] = array('ID' => $post_i->ID, 'Description' => $post_i->post_title);
	}

Now, with the "post reference" field, how can you get all the "printers" related to a manufacturer?
Which of the 2 ways is more efficient?
Do it with "Relationships" or with "post reference"?
Thank you very much for your help.

Regards,
Francisco R.

#1310907

As I mentioned above, the custom "Post Reference" field is based on one-to-many post type relationship, so you can use relationship filter to query related child "Printers" posts, in your custom PHP codes, you can use the "Post Reference" field slug as relationship slug, see our document:
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/#displaying-many-related-items
section "Displaying many related items"

#1311069

Hi Luo,

In the document that you have indicated to me it does not specify anything related to PHP code, but I have been able to solve it, however, this type of field cannot be placed as a column in the dashboard table for the "printers" type.

Is there any way to place this field in the table?

Thanks for your help.

Regards,
Francisco R.

#1311111

For the new question:
Is there any way to place this field in the table?

You are right, there isn't builtin feature within Types plugin, for example:
You can edit your custom post type "printers", in section "Post Fields to be shown as columns in Post Type listing in WordPress Admin", you should be able to see the "Post Reference" field option isn't available.

You can also add a feature request for it:
https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/
Our developers will evaluate it.

#1311147

Where can I see the list of all suggestions for new features?
Thanks Luo.

#1311905

Unfortunately, the feature request list has been removed.

#1312591

So, I can no longer put feature request?
Regarding the issue at hand, I think that relationships should be able to specify whether or not they are mandatory as in the fields.

Thansk for your help.

#1312769

There is a misunderstand, I mean this:
1) You can add the new feature request here:
https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/
Our developers will get the feature request, and evaluate it.

2) But the feature request list has been removed from front-end, only our developers can see the lists.

Hope it is clear

#1312839

My issue is resolved now. Thank you!