cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Derek Hohls" <>
Subject Re: [CForms] Setting dynamic values in selection-list?
Date Tue, 20 Jul 2004 06:22:20 GMT
The way I would approach it, is *not* to write new code
but to make use of the existing functionality in Cocoon.

In your form model, you will have:

    <fd:field id="movie-theme">
      <fd:label>Movie Theme</fd:label>
      <fd:datatype base="string"/>
        <fd:selection-list  src="cocoon:/form-sql/theme.xml"

The source for this list comes from a Cocon pipeline
(assumes you have setup your connection correctly)
which is in your sitemap:

   <!-- === data for form from database list === -->
   <map:match pattern="form-sql/theme.xml">
     <map:generate src="docs/basic-sql.xml"/>
     <!-- === SQL Connector ==== -->       
     <map:transform type="sql">
       <map:parameter name="use-connection" value="movie_user"/>
       <map:parameter name="show-nr-of-rows" value="true"/> 
       <map:parameter name="clob-encoding" value="UTF-8"/> 
     <map:transform src="stylesheets/widget-theme.xsl"/>
     <map:serialize type="xml"/>

Where the two key files are the basic-sql.xml and widget-theme.xsl

basic-sql.xml (to access database and generate datae)

<?xml version="1.0" encoding="UTF-8"?>
  <sq2:execute-query xmlns:sq2=""> 
    <sq2:query name="themes">
       SELECT ThemeID, ThemeDesc FROM MovieTheme

widget-theme.xsl (to create the correct format for the selection list)

<?xml version="1.0"  encoding="UTF-8"?>
<xsl:stylesheet version="1.0"

<xsl:template match="/">

<xsl:template match="fd:selection-list">
  <xsl:apply-templates select="sq2:rowset"/>

<xsl:template match="sq2:rowset">
  <xsl:apply-templates select="sq2:row"/>

<xsl:template match="sq2:row">
  <fd:item value="{sq2:themeid}"><fd:label><xsl:value-of


Hope this helps!

>>> 2004/07/19 09:35:25 PM >>>

I want to display a selection box in my form. I had seen that CForms 
support such kind of formfield: selection-list. But all examples only 
shows handling static values. Is it possible to set the values for the

selection box from a database (dynamically) using the form binding? Do

you have an example about this? Do I need the repeater for this?

Thank you!


To unsubscribe, e-mail: 
For additional commands, e-mail: 

This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
MailScanner thanks transtec Computers for their support.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message