- This topic has 4 replies, 2 voices, and was last updated 4 years, 8 months ago by
mcmaster.
-
AuthorPosts
-
-
June 10, 2017 at 5:50 pm #8274
conkidMemberHi All,
I cannot for the life of me understand why the following code is not working as expected to display properly in view with the default template: field.
I am using the ‘field’ template defined as: “field template for not showing label and 100% width”
Below is my code but I cannot get the 2nd row to display properly with the grid. It is as if the field is being moved to the default location it would be if there were still a label.
<?php /* Title: Details Post Type: intranet_it_tickets Priority: high Context: normal */ piklist('field', array( 'type' => 'group' ,'label' => 'Ticket Details' ,'template' => 'field' ,'fields' => array( array( 'type' => 'number', 'field' => 'ticket_number', 'label' => 'ID', 'columns' => 2, 'attributes' => array( // Pass HTML5 attributes in the attributes array 'placeholder' => 'Ticket #', 'readonly' => 'readonly' ) ), array( 'type' => 'select' ,'field' => 'ticket_user' ,'label' => 'User' ,'columns' => 2 ,'choices' => array( '' => '-Select-' ) + piklist( get_users( array( 'orderby' => 'display_name' ,'order' => 'asc' ,'exclude' => '2' ) ,'objects' ) ,array( 'ID' ,'display_name' ) ) ), array( 'type' => 'select', 'field' => 'ticket_priority', 'label' => 'Priority', 'columns' => 2, 'choices' => array( '' => '-Select-', 'priority_one' => '1 - Urgent - Critical Impact (Priority One)', 'priority_two' => '2 - High - Significant Impact (Priority Two)', 'priority_three' => '3 - Normal/Minor impact (Priority Three)', 'priority_four' => '4 - Low/Informational (Priority Four)', ) ), array( 'type' => 'datepicker' ,'field' => 'ticket_start_date' ,'label' => 'Start Date' ,'columns' => 2 ,'attributes' => array( // Pass HTML5 attributes in the attributes array 'required' => 'required', ) ), array( 'type' => 'datepicker' ,'field' => 'ticket_end_date' ,'label' => 'End Date' ,'columns' => 2 ,'attributes' => array( // Pass HTML5 attributes in the attributes array ) ), array( 'type' => 'select', 'label' => 'Ticket Details', 'field' => 'ticket_support_type', 'columns' => 2, 'choices' => array( '' => '-Select-', 'Hardware' => 'Hardware', 'priority_two' => '2 - High - Significant Impact (Priority Two)', 'priority_three' => '3 - Normal/Minor impact (Priority Three)', 'priority_four' => '4 - Low/Informational (Priority Four)', ) ), array( 'type' => 'select' ,'field' => 'ticket_owner' ,'label' => 'Owner' ,'columns' => 6 ,'choices' => array( '' => 'Select' ) + piklist( get_users( array( 'orderby' => 'display_name' ,'role__in' => array('information_technology', 'administrator') ,'order' => 'asc' ,'exclude' => '2' ) ,'objects' ) ,array( 'ID' ,'display_name' ) ) ), array( 'type' => 'select' ,'field' => 'ticket_owner' ,'label' => 'Owner' ,'columns' => 6 ,'choices' => array( '' => 'Select' ) + piklist( get_users( array( 'orderby' => 'display_name' ,'role__in' => array('information_technology', 'administrator') ,'order' => 'asc' ,'exclude' => '2' ) ,'objects' ) ,array( 'ID' ,'display_name' ) ) ), ) )); -
June 10, 2017 at 5:51 pm #8275
-
June 10, 2017 at 6:46 pm #8280
mcmasterMemberHi @conkid,
I’m running the Piklist 0.10 Beta from Github, which has so far shown itself to be robust and bug-free. Your problem seems to be fixed there (see image).
Two observations: I’m assuming that you know you have two copies of the Owner field. 😉
And I am impressed that you’re able to make sense of code that isn’t consistently formatted. I reformatted it because I wanted to see what you’re doing and because I’m OCD. An unsolicited suggestion from this old programmer: consider creating the user list arrays as variables before defining the field, and then just reference the variables within the field definition. It will make your code easier to follow.
<?php /* Title: Details Post Type: post Priority: high Context: normal */ piklist('field', array( 'type' => 'group', 'label' => 'Ticket Details', 'template' => 'field', 'fields' => array( array( 'type' => 'number', 'field' => 'ticket_number', 'label' => 'ID', 'columns' => 2, 'attributes' => array( // Pass HTML5 attributes in the attributes array 'placeholder' => 'Ticket #', 'readonly' => 'readonly', ) ), array( 'type' => 'select', 'field' => 'ticket_user', 'label' => 'User', 'columns' => 2, 'choices' => array( '' => '-Select-' ) + piklist( get_users( array( 'orderby' => 'display_name', 'order' => 'asc', 'exclude' => '2' ), 'objects' ), array( 'ID', 'display_name' ) ) ), array( 'type' => 'select', 'field' => 'ticket_priority', 'label' => 'Priority', 'columns' => 2, 'choices' => array( '' => '-Select-', 'priority_one' => '1 - Urgent - Critical Impact (Priority One)', 'priority_two' => '2 - High - Significant Impact (Priority Two)', 'priority_three' => '3 - Normal/Minor impact (Priority Three)', 'priority_four' => '4 - Low/Informational (Priority Four)', ) ), array( 'type' => 'datepicker', 'field' => 'ticket_start_date', 'label' => 'Start Date', 'columns' => 2, 'attributes' => array( // Pass HTML5 attributes in the attributes array 'required' => 'required', ) ), array( 'type' => 'datepicker', 'field' => 'ticket_end_date', 'label' => 'End Date', 'columns' => 2, 'attributes' => array( // Pass HTML5 attributes in the attributes array ) ), array( 'type' => 'select', 'label' => 'Ticket Details', 'field' => 'ticket_support_type', 'columns' => 2, 'choices' => array( '' => '-Select-', 'Hardware' => 'Hardware', 'priority_two' => '2 - High - Significant Impact (Priority Two)', 'priority_three' => '3 - Normal/Minor impact (Priority Three)', 'priority_four' => '4 - Low/Informational (Priority Four)', ) ), array( 'type' => 'select', 'field' => 'ticket_owner', 'label' => 'Owner', 'columns' => 6, 'choices' => array( '' => 'Select' ) + piklist( get_users( array( 'orderby' => 'display_name', 'role__in' => array('information_technology', 'administrator'), 'order' => 'asc', 'exclude' => '2' ), 'objects' ), array( 'ID', 'display_name' ) ) ), array( 'type' => 'select', 'field' => 'ticket_owner', 'label' => 'Owner', 'columns' => 6, 'choices' => array( '' => 'Select' ) + piklist( get_users( array( 'orderby' => 'display_name', 'role__in' => array('information_technology', 'administrator'), 'order' => 'asc', 'exclude' => '2' ), 'objects' ), array( 'ID', 'display_name' ) ) ), ) ));Attachments:
You must be logged in to view attached files. -
June 10, 2017 at 10:41 pm #8282
conkidMemberHi McMaster,
Thank you so much for your advice. I tried .010 and was also successful. I will also take your code structure advice and work to implement into my coding. Thanks again for your help!
-
June 11, 2017 at 1:04 am #8283
mcmasterMemberGlad it worked for you!
-
-
AuthorPosts
- You must be logged in to reply to this topic.