Search

Hi guys. I’m nearing the end of my first development project in Symphony, and so far I have to say that I’m pretty impressed with how quickly Symphony has allowed me to put this together, and how flexible it is.

I’m currently trying to implement a contact form, and I’ve run into some difficulties. I followed the Say Hello to Symphony tutorial which contains advice on front-end submission and I’ve used this as a guide to building my form and submitting the data to a section. When I submit the form I can output a success or failure message (utilising the XML returned by the server as described when creating a new event). However, if there is a failure (mandatory field not populated) I’m struggling to tell the user where the error lies because there are several errors being returned and I only really want to display one until there is none left. On top of this the data that the user enters before submission doesn’t persist.

Being the sort of ‘read up in forums and play around with things first’ type of guy, instead of a ‘give up straight away and ask for help’ type of guy, I found Nick Dunn’s Form Controls XSLT Utility which I thought would solve all of my problems. However, damned if I can even get the simplest form to work. I’ve followed the instructions and I’ve confirmed that EXSL is installed, but when I paste Nick’s code (from the section “Most basic example”) into a new page I just get a malformed form (please see the attached screenshot).

I don’t have an event called “save-blog-post” so I used my own. This won’t make a difference will it?

Any help would be greatly appreciated.

Attached screenshot

Attachments:
form.png

I found Nick Dunn’s Form Controls XSLT Utility which I thought would solve all of my problems. However, damned if I can even get the simplest form to work

You’re very brave! Form Controls can look pretty scary to fresh faces to XSLT, but I’m really glad you’re giving it a go. Changing the save-blog-post part to your own event name is the right thing to do, so no problem there.

It looks like the HTML is somehow malformed. Could you post your full XSLT please, perhaps just paste it onto pastie.org and I’ll take a look.

Nick, thanks for taking the time to reply. You seem pretty active on these forums which is a good thing for me! I decided to give Form Controls a go because the amount of code I thought I’d have to write to display one message to the user at a time, or display them all at once in a neat fasion (which I thought in my beginner’s head would consist of lots of xsl:when and xsl:otherwise statements) and ensure that the user input persisted, was going to take me some time. Form Controls seemed like a logical thing to take the time to learn so I can expand my knowledge and utilise a solution that is more efficient and time saving in the long run. What Form Controls proposes sounds great.

I’ve posted the ‘Most basic example’ code onto pastie for your perusal.

Just to give you more information on what I’m trying to achieve, I’ve got a section called Contact Form which contains fields for Name (form submission author), Email, Subject, Message and Date. I’ve also got an event called Submit Contact. On successful form submission, I want to send an email to a designated email address and save the entry into my section. Cheers.

I decided to give Form Controls a go because the amount of code I thought I’d have to write to display one message to the user at a time, or display them all at once in a neat fasion (which I thought in my beginner’s head would consist of lots of xsl:when and xsl:otherwise statements) and ensure that the user input persisted, was going to take me some time

Precisely why I wrote Form Controls :-)

Looks like everything you’ve done is spot on. The reason you’re seeing oddness in your browser is actually because the example is so simple! Take a look at the rendered HTML source in your browser and you’ll see that:

  1. there is an XML declaration at the top <?xml version="1.0"?>
  2. there is no <html> or <body> surrounding your form

If you were to import your master.xsl as you would with other pages, I’m sure this problem will go away. The long and short of it is that somewhere along the line (either in your master.xml you’re importing, or in the page itself if you’re not importing one) you should define an <xsl:output> element, and structure your page as valid HTML.

Here’s a quick example that fixes the problem you were seeing:

http://pastie.org/878005

Hi Nick, thanks for the help. I’ll give it a try and see how I get on. Cheers.

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