Forum Replies Created

Viewing 15 posts - 1 through 15 (of 35 total)
  • Author
    Posts
  • in reply to: Front end File Uploader – Problems with Required #7772
    jrcreative
    Member

    Good 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.

    in reply to: Display Piklist Settings uploaded images repeater field #7429
    jrcreative
    Member

    I 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!

    in reply to: Display Piklist Settings uploaded images repeater field #7427
    jrcreative
    Member

    $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_r it 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
        )
      )
    ));
    
    ?>
    in reply to: front end form #7426
    jrcreative
    Member

    YES 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.

    in reply to: Shortcode form do not wok! #7413
    jrcreative
    Member

    Is your theme folder called ‘theme’? Perhaps there’s a naming conflict? You might try renaming your theme folder to something more specific.

    in reply to: Custom Action on submission of a frontend form #7410
    jrcreative
    Member

    @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.

    in reply to: PDF Plugin or Framework best for Piklist #7409
    jrcreative
    Member

    I’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.

    in reply to: data from grouped fields not showing up on frontend #7335
    jrcreative
    Member

    @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'];
    in reply to: File field 'required' error #7334
    jrcreative
    Member

    @Steve I just got around to looking at the file validation tab in the demos, and it’s not actually checking a file field type. It’s evaluating the contents of a text field to see if that’s a valid file.

    Can validation be done with a file field 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.

    in reply to: Need to set empty title from two fields. #7242
    jrcreative
    Member

    Actually, it was the die() statement that stopped the function from finishing. If you left the print_r and removed the die(); it would have completed, but in a hook, it’s the only way to actually see the output, otherwise it would print_r behind the scenes and move on. You’d never see the result.

    Gotta love those learning moments!

    in reply to: Need to set empty title from two fields. #7238
    jrcreative
    Member

    @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'];
      }
    in reply to: Need to set empty title from two fields. #7218
    jrcreative
    Member

    I 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'];
    
    in reply to: File upload preview and Add More limit in front-end forms #7217
    jrcreative
    Member

    I 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.

    in reply to: File field 'required' error #7216
    jrcreative
    Member

    bump…

    Has anyone come across this before? Any possible solutions I should be looking at?

    in reply to: new docs problems #7192
    jrcreative
    Member

    Appreciate 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!

Viewing 15 posts - 1 through 15 (of 35 total)