I created an options page for my plugin where the user can specify image dimensions which will be saved for later use. So far the image dimensions are entered by the user in one input field like 200x200. To make it easier for the user I want to split that into two input fields with a x between them(one for x, one for y dimension).
My question is: How can I do that and still save those fields as one entry like 200x200? I mean, how can I tell wordpress that these two fields belong together?
So far my options page form looks like this:
<form method="post" action="options.php"> <?php wp_nonce_field('update-options'); ?> Defined sizes so far:<br> <?php foreach($sizes as $size):?> <?php if($size!=""):?> <div class="gpp_size_input"><input type="text" name="gpp_image_sizes" value="<?php echo $size;?>" readonly="readonly"><span class="gpp_minus">-</span></div> <?endif;?> <?endforeach;?> <div class="gpp_size_input"><input type="text" name="gpp_image_sizes"><span class="gpp_plus">+</span></div> <br><br> <input type="hidden" name="action" value="update" /> <input type="hidden" name="page_options" value="gpp_image_sizes" /> <input type="submit" value="Save" /> </form>
As you can see, the already defined sizes get listed and can be removed(that's js in the background) and a new input is created if the user wants to define a new size and save it.