We've had a report of some errors occurring when using ACF Extended's 'Date Range Picker' field in form. The two errors we've seen are as follows:
PHP Warning: Illegal string offset 'start' in /path/to/acf-extended-pro/pro/includes/fields/field-date-range-picker.php
OR
Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /path/to/acf-extended-pro/pro/includes/fields/field-date-range-picker.php
These errors occur on form submission and the reason it happens is because in Advanced Forms, we format all submitted values using ACF's acf_format_value() function as part of the submission. This is so formatted values can then be used in email notifications, success messages, etc.
After some digging, I was able to reproduce the issue with ACF Extended's forms when rendering the formatted field value in an ACFE form success message, indicating that this is a possible bug in the field type's format handler.
A simple workaround for this is to short-circuit the field format handler of that type if/when a string is passed in. You can do so with the following snippet:
<?php add_filter( 'acf/pre_format_value', function ( $null, $value, $post_id, $field ) { if ( $field['type'] === 'acfe_date_range_picker' and is_string( $value ) ) { return $value; } return $null; }, 10, 4 );
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article