acf_field_clone::format_value
This filter is appied to the $value after it is loaded from the db and before it is returned to the template
Method of the class: acf_field_clone{}
No Hooks.
Returns
mixed. $value The modified value.
Usage
$acf_field_clone = new acf_field_clone(); $acf_field_clone->format_value( $value, $post_id, $field, $escape_html );
- $value(mixed) (required)
- The value which was loaded from the database.
- $post_id(mixed) (required)
- The
$post_idfrom which the value was loaded. - $field(array) (required)
- The field array holding all the field options.
- $escape_html(true|false)
- Should the field return a HTML safe formatted value.
Default:false
Changelog
| Since 3.6 | Introduced. |
acf_field_clone::format_value() acf field clone::format value code ACF 6.8.8
public function format_value( $value, $post_id, $field, $escape_html = false ) {
// bail early if no value
if ( empty( $value ) ) {
return false;
}
// modify names
$field = $this->prepare_field_for_db( $field );
// loop
foreach ( $field['sub_fields'] as $sub_field ) {
// extract value
$sub_value = acf_extract_var( $value, $sub_field['key'] );
// format value
$sub_value = acf_format_value( $sub_value, $post_id, $sub_field, $escape_html );
// append to $row
$value[ $sub_field['__name'] ] = $sub_value;
}
// return
return $value;
}