Forums
Forums / Fixing WordPress / Multi select in widget form
(@4nt0n)
10 years, 5 months ago
I am trying to store multi select values from a form in a widget but only the last one is getting stored.
I tried everything I found online with no luck
here is my code
PasteBin
Thanks! 4nt0n
(@greenshady)
It’s probably because you’re using esc_sql() for sanitizing:
esc_sql()
$instance['select'] = esc_sql( $new_instance['select'] );
You should use something like:
$instance['select'] = is_array( $new_instance['select'] ) ? array_map( 'absint', $new_instance['select'] ) : array();
The topic ‘Multi select in widget form’ is closed to new replies.