• Hi All,

    I’ve created a fully functional widget (woot!), and all of my <input> and <textarea> boxes work perfectly, and update correctly.

    Now I am adding a drop-down menu:

    <p>
                <label for="<?php echo $this->get_field_id('orderby'); ?>">Sort:
                <select id="<?php echo $this->get_field_id('orderby'); ?>" name="<?php echo $this->get_field_name('orderby'); ?>" />
                    <option value="asc" <?php if($orderby=='asc') echo 'selected'; ?>>Asc</option>
                    <option value="desc" <?php if($orderby=='desc') echo 'selected'; ?>>Desc</option>
                </select>
                </label>
            </p>

    … and I’m telling it to update in the update() function just like the other fields:

    $instance['orderby'] = strip_tags($new_instance['orderby']);

    Now the dropdown renders perfectly in the widget at first. I select a state, click ‘save’, and suddenly the content of the dropdown disappears completely (i.e. empty dropdown). If I refresh the page, it comes back, and does indeed display the selected value correctly.

    So the menu is working properly, except for the little bug where the content disappears when you click ‘save’. Any thoughts would be greatly appreciated!

    Cheers,
    Adam

  • The topic ‘Widget API: Form tags not updating on 'save'’ is closed to new replies.