Dear Sir/Madam,
As I know, I can preset the options list from a custom field but I prefer not to allow the customer to update the options list from the dashboard, I want to make a CRED form for the customer to add the options list and it can be used in the View custom search. Is it possible to do? Could you give some script if need?
Best regards,
Kelvin.
Hi, there's no way to manage custom field options from the front-end with Forms, unfortunately. You could use Forms to generate posts in some custom post type, then use a generic field to display those posts in a select field in Forms.
Dear Christian Cox,
Could you provide some more information about using the generic field to display those posts in a select field in Forms, do I need to do some code?
If I have many fields need to be done in this way, is it the best practice to create a custom post type (for example named it as myCustomFields) and create all the custom fields' details under this post type, so that I can manage all in one form? How can I ensure the slug won't be duplicated when a customer adds the new option from CRED form?
Do you have some ready-to-make code for me to validate the new options' slug or WordPress can handle this if the slug is duplicated automatically?
Best regards,
Kelvin.
If I have many fields need to be done in this way, is it the best practice to create a custom post type (for example named it as myCustomFields) and create all the custom fields' details under this post type, so that I can manage all in one form?
I'm afraid the workaround I mentioned will not be effective for multiple filters in Views custom searches. Let me explain the problem. In order to use these posts as filters in a custom search View, you must create many-to-many post relationships between these posts and the search post type. However, you can only create one set of many-to-many post relationship filters in a custom search. You cannot filter by multiple M2M post relationships. So if multiple sets of these field filters are required, it will not be possible to set that up in a custom search View. Another option is to use a taxonomy instead of custom fields. Users can select taxonomy terms or create new taxonomy terms in the Form.
Dear Christian Cox,
As my understanding, adding the search from Views is just either query the data of field from database or custom predefined options. I think using the generic field and query the data and convert them into options, I did it before but I can't find it back from support.
The solution should about using a view to create raw data and then import into the generic field content.
Best regards,
Kelvin.
Beda's comment here might be helpful for creating your own generic select field in Forms with dynamic options using a View:
https://toolset.com/forums/topic/select-type-field/
However, this does not change the limitations we discussed earlier. This generic select field does not give Users the ability to create new options for a custom field search filter. Custom field filter options are always predefined in wp-admin, and there is no way to manage them with Forms or any public APIs.
You can use the generic select field to allow Users to select from posts that have already been created (by Forms, or in wp-admin). But then, if you create post relationships using these selected posts, you cannot create multiple post relationship filters in a custom search View. So the limitations here are fairly restrictive.
Dear Christian Cox,
I want to have a CRED form for the customer to update the options list. After adding the options list, the customer can create a post and select the options using the generic select field. After that, I want to have a search form for the visitor to select the option as part of the filter in search. As I create a View, there is a Search and Pagination section, I want to import the options list into the filter controls as a search item to a visitor. I want to use the "Using manually entered values" as the input but query the options list.
[wpv-control-postmeta field="wpcf-estate" source="custom" url_param="wpv-wpcf-estate" values="Option01,Optoin02" display_values="Option 01,Option 02"]
Can I make a view to build the options with syntax like values="Option01,Optoin02" display_values="Option 01,Option 02"?
Best regards,
Kelvin.
We do not recommend using Views as the source of options for a custom field filter. There isn't a good way to keep this list in sync with the field options in wp-admin.
Dear Christian Cox,
I think I find the solution from my other post https://toolset.com/forums/topic/bug-found-from-custom-search/ , although I have not yet implemented it from CRED, I did it from custom search.
Anyway, many thanks for your support.