- This topic has 13 replies, 9 voices, and was last updated 4 years, 11 months ago by
Stephen.
-
AuthorPosts
-
-
February 10, 2016 at 5:40 am #5886
helmiaditya14MemberI tried to include a custom taxonomy dropdown on front-end form, which is displays fine, but the taxonomy selection was not saved on post creation.
After initial creation, if I edit it, then try to save the taxonomy again, it works.
Any idea what I did wrong?
piklist('field', array( 'type' => 'select', 'scope' => 'taxonomy', 'field' => 'product_cat', 'label' => 'Main Category', 'attributes' => array( 'class' => 'form-control' ), 'choices' => array( '' => 'Choose' ) + piklist( get_terms('product_cat', array( 'hide_empty' => false, 'parent' => 0 )), array( 'term_id','name' ) ) )); -
February 10, 2016 at 11:06 pm #5898
SteveKeymaster@helmiaditya14– You’re not doing anything wrong. This appears to be a bug.
-
February 11, 2016 at 4:59 am #5905
helmiaditya14MemberI see. Thanks Steve for the clarification.
I’m wondering if there’s any temporary quick fix for the bugs?
-
February 15, 2016 at 3:24 pm #5931
jivedigMemberJust jumping in to say that this is working fine for me.
piklist('field', array( 'type' => 'radio', 'scope' => 'taxonomy', 'field' => 'program_type', 'choices' => piklist(get_terms('program_type', array( 'hide_empty' => false, )), array( 'term_id', 'name', ) ), 'required' => true, )); -
February 17, 2016 at 2:30 pm #5949
akforsytMemberInterested in this as well. I’m not sure if my problem is part of the same bug, but I’m having problems with saving taxonomies on a front end form.
I have set
piklist('field', array( 'type' => 'hidden', 'scope' => 'taxonomy', 'field' => 'category', 'value' => 'plan' ));When I first submit the form, the post saves with the category ‘Plan’. If I edit the form and save again, the category changes to ‘Array’.
I noticed in source when I go to update the form, it shows two hidden fields for taxonomy.
<input type="hidden" id="_taxonomy_category_0" name="_taxonomy[category]" value="189" class="_taxonomy_category piklist-field-element" data-piklist-field-addmore-clear="0"> <input type="hidden" id="_taxonomy_category_1" name="_taxonomy[category]" value="1" class="_taxonomy_category piklist-field-element" data-piklist-field-addmore-clear="0">189 is the ID of my ‘Plan’ category.
-
March 28, 2016 at 10:44 am #6196
kattagamiMemberI notice the same problem, taxonomy doesn’t save on my front-end form (I use 0.9.9.6 Piklist version).
Is this bug on the roadmap and will be fixed for the next Piklist 1.0 version?
-
May 26, 2016 at 1:12 am #6547
MorganMemberI’m still having this problem in 0.9.9.8
-
November 9, 2016 at 5:35 pm #7507
buishiMemberI’m also having this problem in 0.9.9.9. Anyone figure out a patch?
-
December 9, 2016 at 4:13 pm #7640
hozefasmileMemberIs the frontend form is supported in version 0.9.9.9 ? or its is available in only beta version?
I am trying to create this form for my custom post type book:-
<?php /* Title: Book Submit Method: post Message: Data will be saved as new book. Logged in: true */ // Where to save this form piklist('field', array( 'type' => 'hidden' ,'scope' => 'post' ,'field' => 'post_type' ,'value' => 'book' )); // Post Status on submit piklist('field', array( 'type' => 'hidden' ,'scope' => 'post' ,'field' => 'post_status' ,'value' => 'publish' )); piklist('field', array( 'type' => 'text' ,'scope' => 'post' // post_title is in the wp_posts table, so scope is: post ,'field' => 'post_title' ,'label' => 'Book Title' ,'attributes' => array( 'wrapper_class' => 'post_title' ,'style' => 'width: 100%' ) )); // post category piklist('field', array( 'type' => 'select', 'scope' => 'taxonomy', 'field' => 'book_type', 'choices' => piklist(get_terms('book_type', array( 'hide_empty' => false, )), array( 'term_id', 'name', ) ), 'required' => true, )); // featured image piklist('field', array( 'type' => 'file' ,'scope' => 'post_meta' ,'field' => '_thumbnail_id' ,'label' => 'Featured Image' ,'options' => array( 'modal_title' => 'Add File(s)' ,'button' => 'Add' ) ,'validate' => array( array( 'type' => 'limit' ,'options' => array( 'min' => 1 ,'max' => 1 ) ) ,array( 'type' => 'image' ) ) )); piklist('field', array( 'type' => 'textarea' ,'scope' => 'post' ,'field' => 'post_excerpt' ,'label' => 'About Book' ,'attributes' => array( 'rows' => 10 ,'cols' => 30 ,'class' => 'large-text' ) )); piklist('field', array( 'type' => 'text' ,'scope' => 'post_meta' ,'field' => 'publisher_name' ,'label' => 'Publisher Name' )); piklist('field', array( 'type' => 'text' ,'scope' => 'post_meta' ,'field' => 'writer_name' ,'label' => 'Writer Name' )); piklist('field', array( 'type' => 'text' ,'scope' => 'post_meta' ,'field' => 'isbn_number' ,'label' => 'ISBN Number' ,'help' => 'Provide ISBN Number of the book' )); piklist('field', array( 'type' => 'datepicker', ,'scope' => 'post_meta' 'field' => 'my_date_field', 'label' => 'Date', 'value' => date('M d, Y', time()), // set default value 'options' => array( 'dateFormat' => 'M d, yy' ) )); piklist('field', array( 'type' => 'group' ,'scope' => 'post_meta' ,'field' => 'editor_info' ,'label' => 'Editors Information' ,'list' => false ,'column' => 2 ,'add_more' => true ,'fields' => array( array( 'type' => 'text' ,'scope' => 'post_meta' ,'field' => 'editor_name' ,'label' => 'Editor Name' ,'columns' => 6 ) ,array( 'type' => 'file' ,'scope' => 'post_meta' ,'field' =>'editor_image' ,'label' => 'Upload Image' ,'columns' => 6 ,'options' => array( 'modal_title' => 'Add file' ,'button' => 'Upload' ) ) ) )); // Submit button piklist('field', array( 'type' => 'submit' ,'field' => 'submit' ,'value' => 'Submit' ));tried to add shortcode
[piklist_form form="book-frontend-form" add_on="theme"]on a page but its not working. -
December 9, 2016 at 5:09 pm #7641
hozefasmileMemberOk I have corrected it, it was some code mistake. So now the form is showing and all fields are also working perfect. All data is saving correctly in custom post. The only problem is with taxonomy. Whatever category you choose in the frontend form, its not saving in that category and checking in backend it shows blank in category field.
My codes here again for the category in form php file
// post category piklist('field', array( 'type' => 'select' ,'scope' => 'taxonomy' ,'field' => 'book_type' ,'choices' => piklist(get_terms('book_type', array( 'hide_empty' => false )), array( 'term_id' ,'name' ) ) ,'required' => true, ));In my theme function file this way the custom post type and custom taxonomy has been created
/* Registering new post type */ add_filter('piklist_post_types', 'book_post_type'); function book_post_type($post_types) { $post_types['book'] = array( 'labels' => piklist('post_type_labels', 'Book') ,'public' => true ,'rewrite' => array( 'slug' => 'book' ) ,'supports' => array( 'author' ,'title' ,'excerpt' ,'revisions' ,'thumbnail' ) ,'hide_meta_box' => array( 'slug' ,'author' ,'revisions' ,'comments' ,'commentstatus' ) ); return $post_types; } /* adding custom taxonomy */ add_filter('piklist_taxonomies', 'book_type_tax'); function book_type_tax($taxonomies) { $taxonomies[] = array( 'post_type' => 'book' ,'name' => 'book_type' ,'show_admin_column' => true ,'configuration' => array( 'hierarchical' => true ,'labels' => piklist('taxonomy_labels', 'Book Type') ,'hide_meta_box' => true ,'show_ui' => true ,'query_var' => true ,'rewrite' => array( 'slug' => 'book-type' ) ) ); return $taxonomies; }So not sure where is the issue or what changes need to bee done so that taxonomy fields selected in frontend saves the category for the newly submitted post.
-
December 15, 2016 at 5:31 pm #7656
SteveKeymasterThis is still an open bug. Sorry for the inconvenience.
-
February 18, 2017 at 8:23 am #7797
StephenParticipantThis is a pretty major bug for me, is there any workaround or has anyone pinpointed where the problem is in the code? I will try to take a look…
-
February 18, 2017 at 10:21 am #7798
StephenParticipantWell, in case this helps anyone else out, I made a quick and (very) dirty change to class-piklist-form.php. This change is to account for my two taxonomies, the first one ‘issues’ that is a multi select checkbox list and the second ‘locations’ which is a simple single select dropdown.
Around line 3292, just after
self::$form_submission = $fields_data;I added the following (customize for your taxonomies and list types):
$formobjID = $fields_data['post']['post_type']['object_id']; //gets the object ID from the form data $issues = $fields_data['taxonomy']['my_issues']['request_value']; // gets my issue array submitted $issueIDS = array_map('intval', $issues); //converts to int, because they are strings when submitted for some reason $locations = $fields_data['taxonomy']['my_locations']['request_value']; $locationsIDS = intval($locations); wp_set_object_terms( $formobjID,$issueIDS, 'my_issues' ); wp_set_object_terms( $formobjID, $locationsIDS, 'my_locations' ); -
February 22, 2017 at 4:12 am #7808
StephenParticipantI ran into some problems with my code above, not realizing that this code ALSO runs in the admin, so I needed to modify my code thus:
if (isset($fields_data['_'])) { //checks that this is a front end form submit $formobjID = $fields_data['post']['post_type']['object_id']; //gets the object ID from the form data $issues = $fields_data['taxonomy']['my_issues']['request_value']; if (is_array($issues)) { // checks for array $issueIDS = array_map('intval', $issues); //converts to int, because they are strings when submitted for some reason } else { $issueIDS = intval($issues); //is single value } $locations = $fields_data['taxonomy']['my_locations']['request_value']; if (is_array($locations)) { $locationsIDS = array_map('intval', $locations); } else { $locationsIDS = intval($locations); } wp_set_object_terms( $formobjID,$issueIDS, 'my_issues' ); wp_set_object_terms( $formobjID, $locationsIDS, 'my_locations' ); }Again, hope someone else finds this useful.
-
-
AuthorPosts
- You must be logged in to reply to this topic.