- This topic has 6 replies, 2 voices, and was last updated 6 years, 11 months ago by
justin.
-
AuthorPosts
-
-
March 9, 2015 at 5:19 pm #3407
justinMemberI am trying to add a “notes” section to a post type that will record the current user and date of the note. So i created a “group” field type that had 2 text fields that I tried to lock on_post_status and auto insert the value, and have one textfield option. The problem is that by using the on_post_status it does not work correctly Please see photo. It does not allow me to add multiple notes.
piklist('field', array( 'type' => 'group' ,'field' => 'reg_notes' ,'add_more' => true ,'label' => 'Notes' ,'description' => 'You can add private notes below for internal reference that only team members will see.' ,'fields' => array( array( 'type' => 'text' ,'field' => 'note_author' ,'value' => $current_user->display_name ,'columns' => 3 ,'on_post_status' => array( 'value' => 'approved' ) ) ,array( 'type' => 'text' ,'field' => 'note_date' ,'value' => date("m/d/y") ,'columns' => 2 ,'on_post_status' => array( 'value' => 'approved' ) ) ,array( 'type' => 'textarea' ,'field' => 'note_text' ,'columns' => 7 ,'attributes' => array( 'placeholder' => 'Your Notes' ) ) ) ));Attachments:
You must be logged in to view attached files. -
March 10, 2015 at 9:58 am #3416
-
March 10, 2015 at 10:40 am #3421
justinMemberIdeally that would be great, but I could not figure that out. So instead I was just going to have 2 of the 3 fields in the group always be locked because I automatically set the value to the current date and the current user. But when I try and lock those two fields in the group that allows for add_more, the add more button disappears, and I can now only add a single note instead of multiple notes.
GROUP with add more functionality set to true
- Name (This field will be automatically set to current user, and always be locked)
- Date (This field will be automatically set to current date and always be locked)
- Notes (This field will never be locked-unless it was possible to lock past notes, but that is not what the code above is trying to do.)
-
March 10, 2015 at 10:47 am #3423
SteveKeymaster@justin– No reason to get all fancy and use
get_post_status… the standard HTML attributereadonlywill work, and Piklist makes it super easy to add attributes.Try this:
piklist('field', array( 'type' => 'group' ,'field' => 'reg_notes' ,'add_more' => true ,'label' => 'Notes' ,'description' => 'You can add private notes below for internal reference that only team members will see.' ,'fields' => array( array( 'type' => 'text' ,'field' => 'note_author' ,'value' => $current_user->display_name ,'columns' => 3 ,'attributes' => array( 'readonly' => 'readonly' ) ) ,array( 'type' => 'text' ,'field' => 'note_date' ,'value' => date("m/d/y") ,'columns' => 2 ,'attributes' => array( 'readonly' => 'readonly' ) ) ,array( 'type' => 'textarea' ,'field' => 'note_text' ,'columns' => 7 ,'attributes' => array( 'placeholder' => 'Your Notes' ) ) ) )); -
March 10, 2015 at 4:23 pm #3429
justinMemberThank you. Did not event think about using that. The only other thing now that I am finding is that when you add another field, it is not auto-populated by the value I have inputted. They are just blank.
-
March 10, 2015 at 4:39 pm #3430
SteveKeymaster@justin– The reason that only the first add-more sets the default is to make a better user experience. Change the fields from
texttohtmland it will work:piklist('field', array( 'type' => 'group' ,'field' => 'reg_notes' ,'add_more' => true ,'label' => 'Notes' ,'description' => 'You can add private notes below for internal reference that only team members will see.' ,'fields' => array( array( 'type' => 'html' ,'field' => 'note_author' ,'value' => $current_user->display_name ,'columns' => 3 ) ,array( 'type' => 'html' ,'field' => 'note_date' ,'value' => date("m/d/y") ,'columns' => 2 ) ,array( 'type' => 'textarea' ,'field' => 'note_text' ,'columns' => 7 ,'attributes' => array( 'placeholder' => 'Your Notes' ) ) ) )); -
March 10, 2015 at 4:44 pm #3431
justinMemberThank you for your help.
-
-
AuthorPosts
- The topic ‘on_post_status and Add more’ is closed to new replies.