You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was looking through the source code and noticed that the list of available custom field types seems to be hardcoded.
Perhaps adding functionality to allow plugins to add to this list could be a desirable feature?
For example, a simple use case would be postal codes. Considering formats vary between countries a single input would either be very complex or fail to validate correctly depending on country. Allowing a plugin to define a postal code custom field could allow country-specific validations and functionality whilst keeping the field relatively simple.
Other use-cases could include custom fields to interact with third-party APIs, allowing very specific validations or having certain javascript inputs.
I'd image something like a CustomFieldType class whose descendants are automatically added and each defining standard options the input uses ( required, multiple etc. ), the partial to use when editing a custom field group, how to render the input in a post form, how to validate submitted values and perhaps some callbacks when the field is set.
If desirable I could see about creating a PR for this. Would take some time though as I'd have to get more familiar with the codebase first.
The text was updated successfully, but these errors were encountered:
I was looking through the source code and noticed that the list of available custom field types seems to be hardcoded.
Perhaps adding functionality to allow plugins to add to this list could be a desirable feature?
For example, a simple use case would be postal codes. Considering formats vary between countries a single input would either be very complex or fail to validate correctly depending on country. Allowing a plugin to define a postal code custom field could allow country-specific validations and functionality whilst keeping the field relatively simple.
Other use-cases could include custom fields to interact with third-party APIs, allowing very specific validations or having certain javascript inputs.
I'd image something like a CustomFieldType class whose descendants are automatically added and each defining standard options the input uses ( required, multiple etc. ), the partial to use when editing a custom field group, how to render the input in a post form, how to validate submitted values and perhaps some callbacks when the field is set.
If desirable I could see about creating a PR for this. Would take some time though as I'd have to get more familiar with the codebase first.
The text was updated successfully, but these errors were encountered: