jmacboy
jmacboy

Reputation: 323

default selected value in xforms:select1

How can I set the selected value to a select1 in xforms without using the instance?

For example, i have this instance:

<lEmpleado_Id></lEmpleado_Id>
<sEmpleado_Nm xsi:type="xs:string"></sEmpleado_Nm>
<iCargo_Id xsi:type="xs:int"></iCargo_Id>
<iProfesion_Id xsi:type="xs:int"></iProfesion_Id>

<iHorario_Id xsi:type="xs:int"></iHorario_Id>
<iConcurrencia_Id>1</iConcurrencia_Id>

and I want to make this select1 to take a default value:

<xf:select1 ref="iHorario_Id">
    <xf:label>Horario</xf:label>
    <!--This is the default item I Want to be selected-->
    <xf:item>
        <xf:label>Select a schedule...</xf:label>
        <xf:value>0</xf:value>
    </xf:item>
    <!--End Here-->
    <xf:item>
        <xf:label>Schedule 1</xf:label>
        <xf:value>1</xf:value>
    </xf:item>
</xf:select1>

but when I validate the xforms I want that if that item is selected, the xform don't submit, but if any other item is selected, it submit normally, Ive tryed with <xf:bind but I don't know how to put a minvalue or something like that to that element

Upvotes: 2

Views: 1129

Answers (1)

tohuwawohu
tohuwawohu

Reputation: 13598

xforms:bind is the right direction; you just need to put a constraint on the iHorario_Id element:

<xf:bind nodeset="iHorario_Id" constraint=". gt 0" />

This makes iHorario_Id valid only if its value is greater than 0. So, you could set the initial value of iHorario_Id to 0 to prevent any submission until a schedule is selected.

Upvotes: 2

Related Questions