Forms: taxonomy field type for frontend forms

Hi,

I am using the “Add Page by Form” Plugin to offer a way to add pages in the frontend. What I would like to do now is to add a text field where the user can add tags. Optimally I would like to have something similar to the input field that is used in the admin panel when creating new pages.

For the admin panel there is a taxonomy field type, however this is unavailable for frontend forms. Does anyone know if and how to make this field type available for my form as well? Can you define custom field types for frontend forms per plugin or in a theme?

Thanks in advance for your help,
Paul R.

The second example in the Add Page by Form Plugin README file includes adding extra taxonomy tags.

It uses the regular field type text.

I hope this helps but maybe I’m misunderstanding your question.

Thank you for your answer. I know that I can do this using regular text fields, but I would like to have the “fancy” text field that is used in the admin panel (which allows you to select already existing tags for instance).

I think you mean the Selectize Field type which is available in Admin Blueprint forms only sadly.

Almost, I mean the taxonomy field type. I know that it is only available for admin forms, I was hoping that there is a way to define custom field types for frontend forms that would allow me to replicate the functionality for frontend forms.

In general it would be great when there was no difference in backend and frontend form fields.

There are a number of ways to take a step in that direction or in adding the Taxonomy field type only:

  1. Ask for it in the Form Plugin repository
  2. Suggest it in the Roadmap for Grav 2
  3. Change the Form Plugin and do a pull request
  4. Hire someone to do it (way nr. 3) for you

I found this thread while attempting the same thing: taxonomy field type in the front-end form.

I’m inexperienced, but it seems like the section in https://learn.getgrav.org/16/forms/blueprints/advanced-features#using-function-calls-data entitled “Creating new form field type” could be relevant.

@bleutzinn, could your Add Page By Form plugin use this functionality with the template plugins/admin/themes/grav/templates/forms/fields/taxonomy/taxonomy.html.twig to create a custom form field type that would allow a selection of tags in the front-end form?

This might be a good approach. The plugin function which gets called from the form need not be in the Add Page plugin. It could be just about the only function in a tiny plugin of its own.

Somewhere and quite some time ago I remember to have read that with version 2.0 there will be no more difference between admin (blueprint) and frontend forms. If so it will be in Grav 1.7 since version 2 will not feature new functionality as mahagr wrote in May 2020.

The only problem is when - or should I say if ? - version 1.7 is released. In less than 4 weeks from today the blog post about the release of 1.7 RC1 is over a year old. That is even the latest blog post in general of Grav.

At the moment I’m not able to figure this out. Also I must admit that because of the above mentioned and the much praised benefits of Flex objects and pages being a well kept secret I am kind of loosing my enthusiasm for Grav as a whole. Still hoping things will change for the better though.

1 Like

Thanks for your response. I’m pretty new to grav and I’m curious about the slow release of 1.7 as well. Considering all the time I’ve invested in learning it, I do hope it stays relevant and updated!

I’m sort of interested in Hugo as well… But that’s another topic