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.
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/
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.
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"
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.
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.
Where can I see the list of all suggestions for new features?
Thanks Luo.
Unfortunately, the feature request list has been removed.
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.
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
My issue is resolved now. Thank you!