acf_field_checkbox::update_value
Filters the $value before it is updated in the db.
Method of the class: acf_field_checkbox{}
No Hooks.
Returns
Mixed.
Usage
$acf_field_checkbox = new acf_field_checkbox(); $acf_field_checkbox->update_value( $value, $post_id, $field );
- $value(mixed) (required)
- The value which will be saved in the database.
- $post_id(int|string) (required)
- The post_id of which the value will be saved.
- $field(array) (required)
- The field array holding all the field options.
Changelog
| Since 3.6 | Introduced. |
acf_field_checkbox::update_value() acf field checkbox::update value code ACF 6.8.8
function update_value( $value, $post_id, $field ) {
// bail early if is empty
if ( empty( $value ) ) {
return $value;
}
// select -> update_value()
$value = acf_get_field_type( 'select' )->update_value( $value, $post_id, $field );
// save_custom
if ( $field['save_custom'] ) {
// get raw $field (may have been changed via repeater field)
// if field is local, it won't have an ID
$selector = $field['ID'] ? $field['ID'] : $field['key'];
$field = acf_get_field( $selector );
if ( ! $field ) {
return false;
}
// bail early if no ID (JSON only)
if ( ! $field['ID'] ) {
return $value;
}
acf_get_field_type( 'select' )->append_user_choices_to_field( $value, $post_id, $field );
}
// return
return $value;
}