Tagged: field name
- This topic has 7 replies, 2 voices, and was last updated 6 years, 6 months ago by
Steve.
-
AuthorPosts
-
-
August 10, 2015 at 10:27 am #4177
vagelisMemberHi. I’ve recently made a plugin using piklist to register a custom post type and added some metaboxes to it. The problem is that each field in metabox appears many times and when I try to save a value it’s showing on the other fields too. Apart from that it only saves as draft and cannot be published. I’ve attached some screenshots.
Attachments:
You must be logged in to view attached files. -
August 10, 2015 at 11:00 am #4180
SteveKeymaster@vagelis– Happy to help. Can you post your field code here so we can take a look? Or email the plugin to [email protected]
-
August 10, 2015 at 11:21 am #4181
vagelisMemberThank you for the quick reply and sorry for not posting these before.
This is my post type snippet:
function boats_post_types($post_types) { $post_types['boats'] = array( 'labels' => piklist('post_type_labels', 'Boats') ,'title' => __('Add a new Boat') ,'supports' => array( 'title', 'revisions', ) ,'public' => true ,'taxonomies' => array('category') ,'has_archive' => true ,'rewrite' => array( 'slug' => 'boat' ) ,'edit_columns' => array( 'title' => __('Boat') ,'post_states' => __('Status') ) ,'hide_meta_box' => array( 'slug' ,'author' ) ,'post_states' => true ,'status' => array( 'draft' => array( 'label' => 'Inactive', 'public' => true ), 'active' => array( 'label' => 'Active', 'public' => true ), 'published' => array( 'label' => 'Published', 'public' => true ) ) ); return $post_types; } add_filter('piklist_post_types', 'boats_post_types'); function boats_rewrite_flush() { // codex_boats_init(); boats_post_types(); flush_rewrite_rules(); } register_activation_hook( __FILE__, 'boats_rewrite_flush' );and my metabox snippet:
<?php /* Title: Test Description: Test metabox Post Type: boats Context: normal Priority: high Locked: false Collapse: true */ piklist('field', array( 'type' => 'text' ,'field' => 'field_name' ,'label' => 'Sellers Name' ,'description' => 'Put sellers name here.' ,'attributes' => array( 'class' => 'text' ) )); piklist('field', array( 'type' => 'text' ,'field' => 'field_name' ,'label' => 'Phone' ,'description' => 'Put sellers phone here.' ,'attributes' => array( 'class' => 'text' ) )); piklist('field', array( 'type' => 'text' ,'field' => 'field_name' ,'label' => 'Mobile phone' ,'description' => 'Put sellers mobile phone here.' ,'attributes' => array( 'class' => 'text' ) )); piklist('field', array( 'type' => 'text' ,'field' => 'field_name' ,'label' => 'Email' ,'description' => 'Put sellers email here.' ,'attributes' => array( 'class' => 'text' ) )); piklist('field', array( 'type' => 'text' ,'field' => 'field_name' ,'label' => 'Address' ,'description' => 'Put sellers address here.' ,'attributes' => array( 'class' => 'text' ) )); piklist('field', array( 'type' => 'text' ,'field' => 'field_name' ,'label' => 'Boat name' ,'description' => "Put boat's name here." ,'attributes' => array( 'class' => 'text' ) )); -
August 10, 2015 at 11:28 am #4182
SteveKeymasterEach field name needs to be unique. This is not a Piklist “thing”, but standard on HTML forms… you can’t have more than one field with the same name.
Make sure all of these are unique, and the form should work perfectly:
,'field' => 'field_name'So they should be something like:
,'field' => 'vagelis_sellers_name'
,'field' => 'vagelis_phone'
,'field' => 'vagelis_mobile_phone'It’s always a good idea to prepend your field names with some unique so you don’t conflict with other plugins.
-
August 10, 2015 at 11:37 am #4183
vagelisMemberThanx you Steve! Rookie mistake. It’s working now. And thank you for your advice. I’ll surely follow it. Another thing happening, is that instead of ‘Publish’ on the right, it says ‘Save’ and after pressing it the post gets published as Draft. How can I change that to show publish(as any other post type) and get publish status instead of draft?
Attachments:
You must be logged in to view attached files. -
August 10, 2015 at 11:40 am #4185
SteveKeymasterIf you use custom post statuses, then it will say “save”, since you may not be “publishing”.
Do you need this?
,'status' => array( 'draft' => array( 'label' => 'Inactive', 'public' => true ), 'active' => array( 'label' => 'Active', 'public' => true ), 'published' => array( 'label' => 'Published', 'public' => true ) ) -
August 10, 2015 at 11:45 am #4186
vagelisMemberNot really, Just used it cause I thought it was essential for the metabox to work, following the documentation. I’ve removed it and all is well! Thanx again Steve for your help!
-
August 10, 2015 at 11:47 am #4187
SteveKeymasterGreat. Closing Ticket!
-
-
AuthorPosts
- The topic ‘Double Fields Piklist Metaboxes’ is closed to new replies.