2

The official example ( https://craftcms.com/docs/templating/entry-form ) seems to assume that the form itself is not already on a page which is an Entry. Dropping this form into a template that has an entry loaded already spits out that entry's entry.title or entry.body.

How should this work? We want the "new entry form" to live on a page that the client controls the content for.

2

The saveEntry controller used by the default example returns an entry variable with the newly created item and the applicable error messages. This could be a potential cause of conflict if you have another variable called entry, which is by default pre-loaded in entry templates.

I think you could create a (for example) product.twig template and manually set an entry variable (via ID or slug) called anything else than entry.

| improve this answer | |
  • Hmm, I see what you are suggesting. Thanks. A bit of a PITA though as that will cause issues with template fragments that need the "create entry" entry - things like SEOmatic. Shame we can't define the variable name that the saveEntry controller spits back :/ – Matt Wilcox Jul 6 '17 at 9:16
  • 1
    Well as a workaround you can save the form with an ajax request. In this case, the controller will return a JSON object that you will need to handle via js... not sure if this will translate less work :) – gioppe Jul 6 '17 at 11:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.