Tagged: group field relationship
- This topic has 0 replies, 1 voice, and was last updated 5 years, 6 months ago by
workvista.
-
AuthorPosts
-
-
July 27, 2016 at 1:22 am #7031
workvistaParticipantHi,
I have 2 CPTs – Job Advertisement and Role. Each Job advertisement (or a notice) can have multiple roles.
I am trying to create a admin form for job notice which will allow me to add multiple roles (in place) to a job notice. I am using group field to do this. There is a demo for group related which adds multiple posts to a demo (wp-content/plugins/piklist/add-ons/piklist-demos/parts/meta-boxes/field-relationship.php).
The demo works regular posts. I cannot get it working for a custom post type.
here’s my code :
<?php /* Title: My custom fields Post Type: job_notice */ ?> <?php piklist('field', [ 'type' => 'group', 'label' => 'Add Role', 'relate' => array('scope' => 'post'), 'add_more' => true, 'fields' => array( array('type' => 'hidden', 'field' => 'post_type', 'value' => 'role', 'scope' => 'post'), array('type' => 'hidden', 'field' => 'post_status', 'value' => 'publish', 'scope' => 'post'), array('type' => 'text', 'field' => 'post_title', 'label' => 'Role Name', 'columns' => 6, 'scope' => 'post'), array('type' => 'number','field' => 'number_of_posts' ,'label' => 'Number Of Posts', 'columns' => 3, 'scope' => 'post_meta') ) ]);I expect to create roles having fields – post_status, post_title, number_of_posts that are related to the parent job_notice.
What I get – Roles get created with fields: post_status, post_title.
The field number_of_posts gets saved as a job_notice field inside its post_meta.Also the add mores do no retain the entered values and show the text boxes as empty.
Is this a bug with field relationships ? Can you add some tutorial on group / relationship fields. The fields documentation page says “coming soon” at https://piklist.com/learn/doc/relationships/. It is really hard to implement CPT – CPT relationship similar to the one that demo shows.
Thanks.
-
-
AuthorPosts
- You must be logged in to reply to this topic.