[QUESTION] Why are certain elements restricted to the form tag?
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 #1995
[QUESTION] Binded events are not being loaded (Just work properly on mozilla firefox)
So I am using local Storage. I added some events to the component this way. Every time I add the component it works just fine. However, If...
Issue #1699
[BUG] Link elements are not copyable/deletable
In the editor, if we have link element with some classes, the editor does not allow to copy/delete the element. GrapesJS version: v0.14.50S...
Issue #2297
[Question] Add script using drag and drop that will add elements dynamically
Hey. Thank you for this great project. I'm using it in one of my project and need some help. 1- I have a block element with script in it. T...
Issue #840
[Bug]: When dragging an element, misleading drop placeholder
GrapeJs Version: 13.8 Local Copy JSFiddle: https://jsfiddle.net/austinbiggs/tgsykuq4/ This bug is a bit hard to explain, but should be pret...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.