Search

On a clean install of Symphony 2, I noticed that the "Save Comments" event front-end form code looks different from the actual code on the "Articles" page.

Edit: Moved code to pastebin because the code screws up the thread post.

http://pastebin.com/m1e169ac6

I ask because I'm trying to make a Comment submission form and I remember for Symphony beta 2 rev. 5 that I can copy and paste the front end form code right onto the page I want.

That's when I noticed that the codes don't match up and it explains why my download comment form keeps throwing errors when I try to submit a comment through the front end (And I know its the front end because I tried submitting a comment through the back end and it works fine).

How can I fix this?

Ecko, can you let us know exactly what errors are occurring?

The HTML generated from an Event will include every field in that section. In most cases you will want to customise the HTML to suit your requirements. In the comments example, you don't want to include the Date field since it is auto-populated, nor do you want to include the Authorised checkbox.

The only actual amendment you need to make is fill in the fields[article] value, as indicated by the ellipsis. This needs to be the ID of the article the comment is attached to, since the field represents the Section Link field. Therefore the 'actual' front end form from grabs the ID attribute from the articles data source: articles/entry/@id.

If your Section has no section links then you can most likely copy and paste the event HTML and use it straight away. But if you have a section link, then you will need to populate the hidden field value.

The other addition is the value attributes on the input elements. These ensure that if the event fails and the page reloads, the values of the form elements are persisted. They look to the event and relclaim the posted values, slotting them back into the form.

The error I get is when I try to submit a comment via the front end form for a custom site section. Its like articles, except for weblinks.

Im not sure what you mean with section links. I think you meant replacing "articles" with the appropriate section, right?

<input name="fields[article]" value="{articles/entry/@id}" type="hidden" />

In my section, I would have to replace the three dots with {articles/entry/@id}

So I would need to change

<input name="fields[download]" type="hidden" value="..." />

to

<input name="fields[download]" type="hidden" value="{downloads/entry/@id}" />

Is this right?

Yes, the fields[download] refers to the section link "Download" in your section, just like any other field. If your section link field was called "Linked Page" then the field would be named fields[linked-page].

Its value needs to be the ID of the parent entry you are attaching entries to. So in the Articles/Comments example above, the Comments section has a section link (named "Article") back to the Articles section. Therefore when submitting a comment we need to say which article to attach the comment to. The same applies in your example.

Where this ID value comes from depends on your circumstances. The Articles example grabs the ID from data source XML. So providing you have a data source named "Downloads" that is outputting the correct entry, this will work.

To check, view the HTML source of your form. Check the value of your fields[download] value. Does it match an ID of an entry already in Symphony?

Ive checked the source of the form and the ID matches to an existing entry. But when I try to use the form, it still wont submit anything. Ive tried everything and still wont work.

Things to check:

  • that your event is in fact attached to your page
  • that your submit button is named with the correct action[event-name-here]

Change the action attribute of your form to ?debug so it loads the Debug page when submitting. Inside the events node does your event give an error?

Yes it gives an error.

<message>Entry encountered errors when saving.</message>
<download-entry type="missing" />

Then it show post values etc which are correct.

I'm not sure what <download-entry type="missing"/> refers to.

Sound like this could be the name of your section link field. In the section is the section link field named "Download Entry"? Therefore your hidden field should be named download-entry and not download.

I changed it and it works! Thanks for the help.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details