cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Lundquist>
Subject Re: Input type button
Date Mon, 17 Jan 2005 12:07:39 GMT

On Jan 17, 2005, at 3:25 AM, angeloimm wrote:

> Hi all... i'm using cocoon cforms version 2.1.5......i need to insert  
> an input type="button" in my form; well in order to do this i have  
> done this template:
>     .
>     .
>     .
> <!-- ####### I'LD LIKE THAT THIS FIELD IS A BUTTON ######-->
>         <fd:field id="allegami">
>           <fd:label>Allega File</fd:label>
>           <fd:datatype base="string"/>
>         </fd:field>
> [...snip]
> then i have this jx:nal
> ######## -->
> 	<ft:widget xmlns:ft=""  
> id="allegami">
> 		<fi:styling xmlns:fi=""  
> type="button" value="Scegli File" class="button"  
> onclick="javascript:ShowPopUp('/Nikko/BM/; 
> amp;typeresource=file&amp;amp;campo=' +  
>'allegami','name') + '_FILE')"/>
> 	</ft:widget>
> Well it seems to me all good but if i go an see the form i see the  
> fiel "allegami" as an input type="text"; in fact this is my html  
> output:
> o
> <input type="text" title="" value="Scegli File"  
> id="allegato.0.allegami" name="allegato.0.allegami" class="button"  
> onclick="javascript:ShowPopUp('/Nikko/BM/; 
> amp;typeresource=file&amp;amp;campo=' +  
>'allegami','name') + '_FILE')">

Right.  <fi:styling> sort of assumes that you're supplying attributes  
that are appropriate for the widget, and in this case you have the  
wrong widget :-).  <fi:styling> can't change one widget into another,  
and you can't use <fd:field> to get a button because a button doesn't  
conform to the semantics of a Field.

CForms has two button widgets: Submit and Action, and the difference is  
that Submit triggers form validation and (if valid) a return from  
showForm(), while Action can optionally trigger validation and doesn't  
result in a return from showForm.  So, you use Action for server-side  
interactions (e.g. coded in flowscript) in which the form is  

They key word there is "server side".  If your button doesn't submit  
the form but only does its client-side onclick() thing, then really it  
isn't a CForms button at all!  It's just a button on your page, so you  
should create it the same way you do any other "stuff that is just on  
the page" — just write the HTML in the form template.  Makes sense?


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

View raw message