Extension point to add extra hidden fields? #934
Replies: 2 comments
-
Bump. Is there anyone with the info? 🙏 |
Beta Was this translation helpful? Give feedback.
-
If you have your own attribute processor, then you'll have access to an instance of an As for creating a model that represents some HTML, you can go about it by getting an // To add something like <input type="hidden" name="csrftoken" value="...">
// after the element being processed by your tag processor
var modelFactory = templateContext.getModelFactory()
var inputModel = modelFactory.createStandaloneElementTag("input",
Map.of("type", "hidden", "name", "csrftoken", "value", ...),
AttributeValueQuotes.DOUBLE, false, false
)
structureHandler.insertImmediatelyAfter(inputModel, false) There are a lots of other methods in those classes for creating and inserting models, which you can find in the javadoc links I've provided above. |
Beta Was this translation helpful? Give feedback.
-
Is there an extension point to add extra hidden fields. For issue wimdeblauwe/htmx-spring-boot#36 I would like to add an CSRF hidden field like Thymeleaf itself does when using a form. I already have an HtmxAttributeProcessor, but I am unsure how I could add an extra hidden field from that code.
Any pointers would be highly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions