Hello,
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
<!-- ######## HERE I USE FI STYLING FOR SETTING INPUT TYPE="BUTTON" ######## -->
<ft:widget xmlns:ft="http://apache.org/cocoon/forms/1.0#template" id="allegami">
<fi:styling xmlns:fi="http://apache.org/cocoon/forms/1.0#instance" type="button" value="Scegli File" class="button" onclick="javascript:ShowPopUp('/Nikko/BM/viewcontent.do?path=/& amp;typeresource=file&amp;campo=' + this.name.replace('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/viewcontent.do?path=/& amp;typeresource=file&amp;campo=' + this.name.replace('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 redisplayed.
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?
Cheers, -ml-
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
