Why are certain elements restricted to the form tag?
once i had a use case that was working with a third party component library. in that library the input and form components was available, but the rendering logic was implemented in a way that if input was not placed in the form tag, styles specific to rendering the input tag will not make any effects. so you would end...
Read full answer below ↓Question
I realize it's not a hard requirement and can be customized, but the main demo and some cloned apps carry this idea forward in restricting certain elements (input, textarea, etc) from being dropped anywhere but a form tag.
Was this introduced to show that it can be done or is there something else I'm missing?
Answers (2)
once i had a use case that was working with a third party component library. in that library the input and form components was available, but the rendering logic was implemented in a way that if input was not placed in the form tag, styles specific to rendering the input tag will not make any effects. so you would end up having an ugly input. so i had to restrict the users from dropping inputs anywhere beside the form tag. as an example check this famous library approach similar to this case: f7 cheers.
@timsim00 technically you're totally free to reset this logic. I've set this up just because in HTML and CSS world (no JS) having input without a form wrapper it doesn't make sense.
So, for example, let's take the input component. In grapesjs-plugin-forms the input component has this property draggable: 'form, form *',. To make it draggable anywhere you would just need this code
editor.DomComponents.addType('input', {
model: {
defaults: { draggable: true }
}
})
To make it work properly, place it in a plugin and load it after grapesjs-plugin-forms
Related Questions and Answers
Continue research with similar issue discussions.
Issue #3169
Hi There I am trying to implement an editor where certain sections of the page are editable / droppable etc (i.e a mixed page where some el...
Issue #3252
Does getHtml() remove the inline style property?
I was fiddling with ways that you could change the style of elements inside the canvas and i noticed that by using the color-picker trait t...
Issue #3579
RTE misplaced when opened right after dropping `activeOnRender` component
Version: 0.17.4 Are you able to reproduce the bug from the demo?[x] Yes[ ] No Steps to reproduce:Go to the demoDrop a "Text" block inside t...
Issue #3291
BUG (v0.16.41): the duplicate icon from the icon toolbar is modifying the original element too
Version: v0.16.41 Are you able to reproduce the bug from the demo? [ ] Yes What is the expected behavior? The elements duplicated not shoul...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.
Browse free plugins →Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.
Browse premium plugins →Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.