Form is not submitting
Question
I am trying to create as custom block. But the form is not submitting when i use components inside content.
const blockManager = editor.BlockManager;
blockManager.add("pre-made-element--registration", {
label: "Registration Form",
category: "Pre-Made Elements",
attributes: { class: "fa fa-user-plus" },
content: {
script: function () {
const $ = window.$;
const form = $(this).find("form");
form.submit((event) => {
const formData = form.serializeArray();
console.log(data);
});
},
components: "HERE IS THE FORM COMPONENT",
},
});
};
I am able to get all the form data when i use content instead of component. But then it's not allowing me drag new inputs to form.
const blockManager = editor.BlockManager;
blockManager.add("pre-made-element--registration", {
label: "Registration Form",
category: "Pre-Made Elements",
attributes: { class: "fa fa-user-plus" },
content: {
script: function () {
const $ = window.$;
const form = $(this).find("form");
form.submit((event) => {
const formData = form.serializeArray();
console.log(data);
});
},
content: "HERE IS THE FORM COMPONENT",
},
});
};
Answers (3)
The important part - the html is missing. If you can, you should share the code in codesandbox or similar online editors.
Yeah, we need the complete code to understand the issue.
Anyway, if you're using script please define a Custom Component instead of placing it directly in the Block, or you'll face issues on storing. I know that this is how is illustrated in the documentation but the usage of blocks was there only as an example (I hope to update it for the next release)
This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #2417
API in Component not working after Deployment
Block.js => Component.js => We are able to call the API and it works in Deployment when we are passing the whole html with script, body, st...
Issue #1034
insert element or block inside parent element
Good day, i have component, have block i have Trait on listen changes, how can I add "h1 " inside that block "'<div class="container" style...
Issue #3203
Custom block category question
Hi, I want add attributes to the category of blocks but the don’t apply.
Issue #2074
Can not use space while editing drop down menu in block manager
hello @artf I have applied a drop down menu in block manager the code is given below It works fine but whenever I try to change the dropdow...
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.