Forum Replies Created
-
AuthorPosts
-
jrcreativeMemberGood news! I’ve come up with a solution.
My first idea was to pre-populate the file input value based on the contents of post_meta and couldn’t figure out why that wasn’t working until I found that it’s actually a security feature to disable that behavior.
So I decided to make the file field conditionally required. If no file is in post_meta I require the field, otherwise you can update the info, but it’s not required.
piklist('field', array( 'type' => 'file' ,'scope' => 'post_meta' ,'field' => 'government_id' ,'description' => __('This can be a driver\'s license, passport, or other official document with your name and photo.') ,'label' => __('Government Issued Photo ID') ,'required' => get_post_meta( $post_id, 'government_id', true ) ? false : true ));It’s not a perfect solution. If someone had previously uploaded a file and came back to the form, they could remove the image with the “Deselect” button and move forward without the file in place. For me, it’s better than not requiring the field.
October 12, 2016 at 2:33 pm in reply to: Display Piklist Settings uploaded images repeater field #7429
jrcreativeMemberI don’t mind helping at all, however, working with multi-dimensional arrays might be too generic a topic for this forum. Stack overflow or the documentation at php.net might be a better fit. Post any Piklist questions here, though!
October 11, 2016 at 6:49 pm in reply to: Display Piklist Settings uploaded images repeater field #7427
jrcreativeMember$image_ids = $image_up[image]; // Get all the IDs
This line doesn’t get all of the ids like you’re expecting. Based on the result of your ‘print_r’ $image_up[image] doesn’t exist.
And you’re wiping out your image_ids array with this line:
$image_ids = count($image_ids)-1;From the results of your
print_rit looks like maybe you’ve tried this a couple of different ways and have some mixed up meta stored in the options table. Here’s a cleaned up version of the meta box to get you started.<?php /* Title: Theme Settings Section Setting: my_theme_settings */ piklist('field', array( 'type' => 'group' ,'field' => 'slides_basic' ,'add_more' => true ,'label' => __('Slide Images with Basic uploader') ,'description' => __('Basic uploader') ,'fields' => array( array( 'type' => 'file' ,'field' => 'image' ,'label' => __('Slides') ,'columns' => 12 ,'options' => array( 'modal_title' => __('Add File(s)') ,'button' => __('Add') ) ) ,array( 'type' => 'text' ,'field' => 'url' ,'label' => __('URL') ,'columns' => 12 ) ) )); ?>
jrcreativeMemberYES it’s possible.
How hard would it be? That’s tough to answer not knowing what is required or what your skill level as a programer is.
I’d say dive in and give it a shot, and as you run into questions, post them here for the community to help out with.
jrcreativeMemberIs your theme folder called ‘theme’? Perhaps there’s a naming conflict? You might try renaming your theme folder to something more specific.
jrcreativeMember@tirins007’s idea would work, but it would create an empty post for each form submission.
https://www.sitepoint.com/handling-post-requests-the-wordpress-way/
I haven’t married the info in the article above with a Piklist front end form, so this is a bit theoretical, but it should get you in the right direction. At some point I’d like to write this specifically into the Piklist docs, but until then this is where I’d start.
jrcreativeMemberI’m using TCPDF in a plugin that I’m building with Piklist. That said, there’s nothing in Piklist that would limit your choice of PDF libraries depending on your needs.
TCPDF has tons of examples and is really simple to implement.
September 13, 2016 at 3:30 pm in reply to: data from grouped fields not showing up on frontend #7335
jrcreativeMember@intrepidrealist Grouped fields are stored as serialized data within the main group field.
There are two ways you can get at the data you want.
1. Remove the line
,'field' => 'birthday_group'and it will store the fields in the group as individual post_meta fields. That would be a simple solution and your code for display above should work.2. Access the data within ‘birthday_group’ and unserialize it. From there you’ll be able to access the individual elements.
$birthday = get_post_meta($post->ID, 'birthday_group',true); $birthday = maybe_unserialize($birthday); // a nice WordPress function that checks if the content is actually serialized data echo $birthday['birth_month'].' '; echo $birthday['birth_day'].', '; echo $birthday['birth_year'];
jrcreativeMember@Steve I just got around to looking at the file validation tab in the demos, and it’s not actually checking a
filefield type. It’s evaluating the contents of atextfield to see if that’s a valid file.Can validation be done with a
filefield type?I don’t need it to validate that it’s a valid file, I would be satisfied if it validated as true if it sees a string of any kind stored in that post_meta field.
jrcreativeMemberActually, it was the
die()statement that stopped the function from finishing. If you left theprint_rand removed thedie();it would have completed, but in a hook, it’s the only way to actually see the output, otherwise it wouldprint_rbehind the scenes and move on. You’d never see the result.Gotta love those learning moments!
jrcreativeMember@intrepidrealist this code in your functions.php should do the trick then.
add_filter('piklist_empty_post_title', 'cazooz_new_title', 10, 2); function cazooz_new_title($data, $post_array) { $new_title = $post_array['_post_meta']['child_first_name'] . " " . $post_array['_post_meta']['child_last_name']; return $post_array['post_type'] == 'child' ? $new_title : $post_array['post_title']; }
jrcreativeMemberI just tested it and it works for me. You should be able to drop it into your functions.php you’re good to go as long as child_first_name’s value is a string.
And for getting both first and last name, you’ll want to do something like this:
$new_title = $post_array['_post_meta']['child_first_name'] . " " . $post_array['_post_meta']['child_last_name'];August 22, 2016 at 4:18 pm in reply to: File upload preview and Add More limit in front-end forms #7217
jrcreativeMemberI would appreciate this, too.
I have a front-end form with a file uploader, and an add-more field that I want to force to have a minimum of 3 items. The server side validation works fine, but a side-effect of server-side only validation is if they only put in 2 items and submit, it errors and comes back to the page wiping out everything that was submitted and they have to re-upload/enter everything.
I see that there is a checkbox in piklist settings to use front-end validation, but it doesn’t seem to apply to these field types.
jrcreativeMemberbump…
Has anyone come across this before? Any possible solutions I should be looking at?
jrcreativeMemberAppreciate it, @Steve!
And if you have a list of holes in the docs that you want to see filled, shoot me an email and let me know if I can contribute. Piklist enabled me to take on a project I didn’t think I was capable of, and has been the catalyst for so much growth in my own dev skills. Now it’s the first plugin I install on any project. It would be an honor to give back!
-
AuthorPosts