Skip Navigation

[Resolved] Custom field “file” is now requiring full url

This thread is resolved. Here is a description of the problem and solution.

Problem:

Disable URL validation of custom file field.

Solution:

There is a workaround by using custom codes, for example if your custom file field slug is "my-file", you can add below codes into your theme/functions.php:

https://toolset.com/forums/topic/custom-field-file-is-now-requiring-full-url/#post-1192315

Relevant Documentation:

This support ticket is created 6 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 7 replies, has 2 voices.

Last updated by Luo Yang 6 years ago.

Assisted by: Luo Yang.

Author
Posts
#1190746

I have a custom field group for custom post attachments using the "file" type. This filed type is now requiring a full url when previously it would allow for a relative path. We are unable to make updates to the parent post without adding a full url.

Because we are using a dev version of the site on a subdomain, adding the full url here will cause problems when the site is pushed to the live environment. How an I disable the full url validation on this field?

#1190855

Hello,

You can edit the custom URL field setting, change option "Field type" to "Single line", for example:
Dashboard-> Toolset-> Custom Fields
find and edit that custom URL field, change the option "Field type" to "Single line", and test again.

#1191242

Thanks, this does work, and seems like a good temporary work around. However, this leaves other users without the file upload dialog for adding attachements to other posts like this one.

#1191741
Validation-URL.JPG

You can also edit the custom URL field, disable option "Validation": URL, see screenshot Validation-URL.JPG

#1192177

The field type I am using is "File". I do have Validation:Required unchecked, but it still validates for a full url as the file path. Unfortunately there is no other option for the field type that I see.

#1192315

Yes, you are right, there isn't other option for the file field type.

There is a workaround by using custom codes, for example if your custom file field slug is "my-file" with filter hook "toolset_filter_field_definition_array", you can add below codes into your theme/functions.php:

add_filter('toolset_filter_field_definition_array', function($config, $filter_validation){
	if($config['id'] == 'my-file'){
		unset($config['data']['validate']);
	}
	return $config;
}, 11, 2);

Please replace "my-file" with your custom file field slug, and test again.

#1199504
edit-post-type.png
methodology-report.png

Thanks Luo!

#1199565

You are welcome