Save and Array of values into a Widget setting
-
Hi, I have the following code inside a custom Widget
function update( $new_instance, $old_instance ) { $instance = $old_instance; /* Strip tags (if needed) and update the widget settings. */ $instance['title'] = strip_tags( $new_instance['title'] ); $instance['posts_id'] = strip_tags( $new_instance['posts_id'] ); $instance['post_per_query'] = strip_tags( $new_instance['post_per_query'] ); $instance['thumb_w'] = strip_tags( $new_instance['thumb_w'] ); $instance['thumb_h'] = strip_tags( $new_instance['thumb_h'] ); $instance['show_events'] = strip_tags( $new_instance['show_events'] ); return $instance; }
$instance[‘posts_id’] has to contain an array of values from a multivalues <select> input. Using this code nothing saves on this variable.
The input code is:
<p> <label for="<?php echo $this->get_field_id( 'posts_id' ); ?>[]">Selecciona servicios relacionados:</label><br /> <select name="<?php echo $this->get_field_id( 'posts_id' ); ?>[]" multiple="multiple" size="5" style="width: 96%; height: auto;"> <?php // The code here generates the <options> ?> </select> </p>
Any advice please???
- The topic ‘Save and Array of values into a Widget setting’ is closed to new replies.