Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to create a repeatable field an upload image input with image preview for my Theme Options page and I have the following:

function theme_options_validate( $_POST ){

if (isset($_POST['submit']) ) {
$theme_options = array();
    foreach ($_POST['image'] as $key => $value) {
        if (empty($value))  continue; 
        $theme_options[] = array(
            'image'     => $_POST['image'][$key],
        );
    }
$valid_input['image'] = $_POST['image'][$key];
}

return $valid_input;

}

for this input:

<input type="hidden" class="image" name="custom_options[image][]" value="<?php echo esc_url( $theme_options['image'] ); ?>" />

So far, everything works fine, the problem is that I'm using jQuery .clone() to clone this input and add more images, but the clone always overwrite the original input when submitting!

Tried using jQuery to count the input as well(name="custom_options[image][0],[1],[2]..."), but have had no luck, the clone never returns.

Any idea on how can I fix this?

share|improve this question
    
Well you need to show use the .clone code, but this sounds more like a jQuery question. –  Wyck Oct 22 '12 at 3:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.