Issue #3207Opened December 23, 2020by shkhalid1 reactions

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)

gixid192December 24, 20201 reactions

The important part - the html is missing. If you can, you should share the code in codesandbox or similar online editors.

artfDecember 31, 20200 reactions

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)

no-response[bot]January 10, 20210 reactions

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.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.