Difficulty with a form

steelej's Avatar

steelej

11 Mar, 2014 07:03 PM

Good day. We have a vendor who is creating forms for tracking inquiries. Until now, for simplicity sake and because the vendor often uses sloppy code, we've been editing them in html and publishing them.

As the use of these is going to increase and there is information on the pages that will be edited we're trying to Cascade so we can drop the form into a region and allow the users to edit the text in the other regions as needed.

I set up a data definition with a WYSIWYG region for inserting the text. I have not yet been able to write a script to properly render a working form, getting various errors depending on what non-working script I'm trying. I've tried escaping, protecting, passing through, all to no avail.

I've attached a working html form. Can you suggest how i would render this in Velocity using a data definition?

  1. 1 Posted by steelej on 11 Mar, 2014 07:45 PM

    steelej's Avatar

    Atttaching xml example

  2. 2 Posted by Ryan Griffith on 12 Mar, 2014 12:38 PM

    Ryan Griffith's Avatar

    Hi Jim,

    Just to clarify, you are looking to output the contents of the <form> element using Velocity? If so, have you tried using the SerializerTool to output the content? For example:

    #set ($form = $callingPageSD.getChild("form"))
    $_SerializerTool.serialize($form, true)
    

    If you still encounter render errors, perhaps try surrounding the output of the form with a #protect code section.

    Please let me know if you have any questions.

    Thanks!

  3. 3 Posted by steelej on 12 Mar, 2014 01:13 PM

    steelej's Avatar

    I've tried both. When using the serializer alone, I get an error saying it can't find the </form> tag:

    An error occurred: Could not transform with Script format "_internal/formats/form-page/form": Error on line 308: The element type "form" must be terminated by the matching end-tag "".

    When I add the protect tag, I get:

    An error occurred: Could not transform with Script format "_internal/formats/form-page/form": Error on line 6: The string "--" is not permitted within comments.

  4. 4 Posted by Ryan Griffith on 12 Mar, 2014 01:29 PM

    Ryan Griffith's Avatar

    Hm, looks like my sample code was a little off. You would want something more like the following:

    #set ($form = $callingPageSD.getChild("form").getChild("content"))
    $_SerializerTool.serialize($form, true)
    

    Perhaps give that a try and let me know how it works out.

    Please let me know if you have any questions.

    Thanks!

  5. 5 Posted by steelej on 12 Mar, 2014 01:53 PM

    steelej's Avatar

    Ryan,
    I had corrected for that:

    #set ($form = $_XPathTool.selectSingleNode($contentRoot, "/system-index-block/calling-page/system-page/system-data-structure/form/content"))

    <!--#protect
    $_SerializerTool.serialize($form, true)

    #protect-->

    Still the errors are as before.

  6. 6 Posted by Ryan Griffith on 12 Mar, 2014 07:08 PM

    Ryan Griffith's Avatar

    Hm, I was not able to reproduce this in my local Cascade Server 7.10 instance. Here are the steps I used to reproduce:

    • Uploaded your sample XML as an XML Block
    • Created the following Velocity Format:
      #set ( $callingPageSD = $_XPathTool.selectSingleNode($contentRoot, "//calling-page/system-page/system-data-structure") )
      #set ($form = $callingPageSD.getChild("form").getChild("content"))
      $_SerializerTool.serialize($form, true)
      
    • Attached both the block and format to a page region
    • Previewed the page and the form rendered as expected.

    I have a few additional questions to see if we can narrow things down a bit:

    • What version of Cascade Server are you currently running?
    • How are you applying this Format? Can you describe how things are set up?
    • Do you have any XSLT Formats applied at the page, template, or configuration set level that may be affecting the output of the page?

    Please let me know if you have any questions.

    Thanks!

  7. 7 Posted by Ryan Griffith on 17 Mar, 2014 03:36 PM

    Ryan Griffith's Avatar

    Hi Jim,

    Just wanted to follow up to see if you had a chance to view my recent comment. Were you able to get your form HTML to output correctly?

    Please let us know if you have any questions.

    Thanks!

  8. 8 Posted by steelej on 17 Mar, 2014 03:48 PM

    steelej's Avatar

    Ryan,

    Sorry I didn’t get back to you. The script you sent did work fine. For the life of me I can’t figure out why mine didn’t. This isn’t a difficult script and to my eye, what I did was the same as what you sent. Mysteries of life. Thanks for your help as always.

    Jim

  9. 9 Posted by Ryan Griffith on 17 Mar, 2014 07:00 PM

    Ryan Griffith's Avatar

    Thank you for following up, Jim. I am glad to hear you were able to get things working.

    Have a great day!

  10. Ryan Griffith closed this discussion on 17 Mar, 2014 07:00 PM.

Discussions are closed to public comments.
If you need help with Cascade CMS please start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

 

26 Aug, 2016 01:19 PM
25 Aug, 2016 03:02 PM
25 Aug, 2016 12:50 PM
24 Aug, 2016 08:43 PM
24 Aug, 2016 07:20 PM
21 Aug, 2016 01:20 PM