cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Derek Hohls" <DHo...@csir.co.za>
Subject Re: Forms styling: showing required OR validation symbols
Date Fri, 03 Sep 2004 10:07:39 GMT
Thanks Jorge - that works well... next question
then is if there is any quick way to alert a user
as to when there is an error anywhere in a form;
a message could then be displayed alterting him
to the fact (say, at the top of the form) and that
he should look for field/s with the "!!" mark and
make corrections as needed.

Thanks
Derek

>>> joerg.heinicke@gmx.de 2004/09/03 10:20:28 AM >>>
On 03.09.2004 08:41, Derek Hohls wrote:

> The current forms stylesheets supplied with Cocoon
> work very well for most purposes... however, I now
> have a quite crowded form where space is at a 
> premium.  Ideally I would only like to have one "hint"
> symbol next to each field ie. if the field is required it
> will have a "*".   But if the user neglects to fill in that
> field, and the form is redisplayed, there is a "!!" and "*"
> This is actually redundant and also causes the form field
> alignments to go out of sync.  
> 
> If anyone knows of a way to ONLY display the validation
> symbol and NOT the required symbol as well, please
> let me know.

That's really easy :)

In forms-field-styling.xsl there is the following template:

   <!--+
       | Common stuff like fi:validation-message, @required.
       +-->
   <xsl:template match="fi:*" mode="common">
     <!-- validation message -->
     <xsl:apply-templates select="fi:validation-message"/>
     <!-- required mark -->
     <xsl:if test="@required='true'">
       <span class="forms-field-required"> * </span>
     </xsl:if>
   </xsl:template>

As you can see easily it results in both the ! and the *. If you import

this stylesheet (or forms-samples-styling, which imports the 
forms-field-styling) you can overload the template, e.g. with the
following:

   <xsl:template match="fi:*" mode="common">
     <xsl:variable name="validation-message">
       <xsl:apply-templates select="fi:validation-message"/>
     </xsl:variable>
     <xsl:copy-of select="$validation-message"/>
     <xsl:if test="@required='true' and
                   not(normalize-space($validation-message))">
       <span class="forms-field-required"> * </span>
     </xsl:if>
   </xsl:template>

Joerg

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org 
For additional commands, e-mail: users-help@cocoon.apache.org 


-- 
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: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message