Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sortable repeatable fields with WP Alchemy
<?php //global $wpalchemy_media_access; ?>
<div class="my_meta_control">
<p id="warning" style="display: none;background:lightYellow;border:1px solid #E6DB55;padding:5px;">Order has changed. Please click Save or Update to preserve order.</p>
<p style="overflow: hidden;"><a href="#" class="dodelete-info button" style="float:right;">Remove All</a> </p>
<?php while($mb->have_fields_and_multi('info')): ?>
<?php $mb->the_group_open(); ?>
<?php $mb->the_field('fullname'); ?>
<label for="<?php $mb->the_name(); ?>">Full Name</label>
<p><input type="text" id="<?php $mb->the_name(); ?>" name="<?php $mb->the_name(); ?>" value="<?php $mb->the_value(); ?>" /></p>
<?php $mb->the_field('title'); ?>
<label for="<?php $mb->the_name(); ?>">Title</label>
<p><input type="text" id="<?php $mb->the_name(); ?>" name="<?php $mb->the_name(); ?>" value="<?php $mb->the_value(); ?>" /></p>
<?php $mb->the_field('phone'); ?>
<label for="<?php $mb->the_name(); ?>">Phone</label>
<p><input type="text" id="<?php $mb->the_name(); ?>" name="<?php $mb->the_name(); ?>" value="<?php $mb->the_value(); ?>" /></p>
<?php $mb->the_field('email'); ?>
<label for="<?php $mb->the_name(); ?>">Email</label>
<p><input type="text" id="<?php $mb->the_name(); ?>" name="<?php $mb->the_name(); ?>" value="<?php $mb->the_value(); ?>" /></p>
<a href="#" class="dodelete button">Remove</a>
<?php $mb->the_group_close(); ?>
<?php endwhile; ?>
<p style="margin-bottom:15px; padding-top:5px;"><a href="#" class="docopy-info button">Add</a></p>
</div>
<script type="text/javascript">
(function ($) {
$(function () {
$("#wpa_loop-info").sortable({
change: function(){
$("#warning").show();
}
});
});
}(jQuery));
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment