Get 2024 Templates Mega Bundle!14 Bootstrap, Vue & React Templates + 3 Vector Sets
Get for 99$

Need Guidance on Form Submission Using Views in Keenthemes Metronic Starter Kit


I'm currently facing a challenge while working with the Metronic Starter Kit, specifically regarding form submissions. Typically, I'm accustomed to submitting requests, such as signing up users, through views. However, in the Metronic Starter Kit, JavaScript is employed to handle form submissions.

My specific question is: How can I submit a form using a view, for instance, the AuthSignupView, while still leveraging the features provided by the Metronic Starter Kit, such as error handling associated with the element ID 'kt_sign_up_submit'?

I appreciate any guidance or examples you can provide to help me overcome this hurdle. Thank you in advance for your assistance.

Best regards


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (2)


Hi,

To submit a form using a view in the Keenthemes Metronic Starter Kit, you need to customize the JavaScript code that handles the form submission. The provided JavaScript file seems to handle both regular form submissions and AJAX form submissions examples. /js/custom/authentication/sign-up/general.js

Update the form selector in the init function to match the ID of your form:

form = document.querySelector("#kt_sign_up_form");


Based on your requirement, choose between regular form submission and AJAX form submission.

For Regular Form Submission:
If you want to submit the form without AJAX, ensure that the isValidUrl function returns false for the form's action. The handleForm function should be called.

handleForm();

Uncomment to submit form for using view form.

//form.submit();


For AJAX Form Submission:
If you want to submit the form using AJAX, ensure that the isValidUrl function returns true for the form's action. The handleFormAjax function should be called.

handleFormAjax();


Thanks



Thanks so much for your answer!


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(