Title: Validate select option value before saving
Last modified: August 22, 2016

---

# Validate select option value before saving

 *  Resolved [Runo](https://wordpress.org/support/users/runo/)
 * (@runo)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/validate-select-option-value-before-saving/)
 * Okay, so I have these select fields with a huge number of options in my forms
   and I realized there was nothing in place in the actual ACF plugin that could
   stop someone from changing the value from one of those options to whatever the
   heck they wanted, saving and then wreaking havoc in my website.
 * Is there a simple way to check before saving if the value being saved actually
   exists in the select options for that field?
 * [https://wordpress.org/plugins/validated-field-for-acf/](https://wordpress.org/plugins/validated-field-for-acf/)

Viewing 1 replies (of 1 total)

 *  Plugin Author [doublesharp](https://wordpress.org/support/users/doublesharp/)
 * (@doublesharp)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/validate-select-option-value-before-saving/#post-5942981)
 * Yes, you would just need to load the ACF field based on the `$this_key` and `
   $post_id` values, then you `in_array()` on the `$field['choices']`. See the [get_field_object()](http://www.advancedcustomfields.com/resources/get_field_object/)
   docs for more info.
 * This is not tested, but it would be something like this:
 *     ```
       $field = get_field_object( $post_id, $this_key, false );
       if ( ! in_array( $value, $field['choices'] ) ){
           $message = "this is not a valid option";
           return false;
       }
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Validate select option value before saving’ is closed to new replies.

 * ![](https://ps.w.org/validated-field-for-acf/assets/icon-256x256.png?rev=1116693)
 * [Advanced Custom Fields: Validated Field](https://wordpress.org/plugins/validated-field-for-acf/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/validated-field-for-acf/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/validated-field-for-acf/)
 * [Active Topics](https://wordpress.org/support/plugin/validated-field-for-acf/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/validated-field-for-acf/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/validated-field-for-acf/reviews/)

## Tags

 * [select field](https://wordpress.org/support/topic-tag/select-field/)

 * 1 reply
 * 2 participants
 * Last reply from: [doublesharp](https://wordpress.org/support/users/doublesharp/)
 * Last activity: [11 years, 2 months ago](https://wordpress.org/support/topic/validate-select-option-value-before-saving/#post-5942981)
 * Status: resolved