Skip to content
Hub Nexus

No author yetClaim it

Version 1Updated 2 min read

Support

Motivation

Forms frequently need to display fields that are not editable by the user. The following program demonstrates this feature.

This is done in XForms using a binding and a style sheet.

A single field (or group of fields) can be marked as read-only with a single bind statement. For example, suppose you had a set of fields related to shipping supplies to remote staff in your IT department. The billing address could not be changed, only who an item was shipped to.

The following single line in the model would make all of the sub-elements of BillToAddress read-only:

nodeset="/PurchaseOrders/BillToAddress" readonly="true()" />

Note that because of CSS, all the fields under this binding will be marked read-only. This is one good reason you may want to logically group read-only data elements in an application.

Sample Program

XHTML XForm

xmlns="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms">

Demonstration of Read-Only Binding
rel="stylesheet" type="text/css" href="table-form.css" />

xmlns="" src="PurchaseOrder.xml" />

nodeset="/PurchaseOrder/BillToAddress" readonly="true()" />

ref="/PurchaseOrder/BillToAddress">
class="box-label">Billing Address :
ref="OrganizationName">
Organization Name:

ref="LocationStreetFullText">
Street:

ref="LocationStreetFullText2">
/>

ref="LocationCityName">
City:

ref="LocationStateName">
State:

ref="LocationPostalID">
Postal Code:

ref="/PurchaseOrder/ShipToAddress">
class="box-label">Shipping Address :
ref="PersonName">
Person Name:

ref="LocationStreetFullText">
Street:

ref="LocationStreetFullText2">
/>

ref="LocationCityName">
City:

ref="LocationStateName">
State:

ref="LocationPostalID">
Postal Code:

Sample Instance Data (PurchaseOrder.xml)

xmlns="">

MegaCorp IT Dept.
123 Main St.
Mailstop 47
Anytown
Minnesota
55123

John Jones
123 Main Street SE
Apartment 123
Anytown
Minnesota
55123

XForms tabular layout stylesheet (table-form.css)

/* a stylesheet for tabular XForms input field alignment */

@namespace xf url("http://www.w3.org/2002/xforms");

/* give the input form labels and the fieldset legend a bold sans-serif font */
label {
font-family: Arial, Helvetica, sans-serif;
font-weight: bold;
font-size: small;
}

xf|group {
border: black solid 2px;
padding: 5px;
width: 300px;
}

/* the labels are right-aligned in a 150px wide column */
xf|input xf|label {
width: 150px;
margin: 3px;
text-align: right;
}

/* the input values are left aligned */
xf|value {
text-align: left;
}

/* vertical area between input boxes */
input {
margin: .2em;
}

/* each input is a row in the group table */
xf|input {
display: table-row;
}

/* each label within an input is a cell in the input row */
xf|input xf|label {
display: table-cell;
}

/* each value (pseudo-element) is also a cell in the input row */
xf|input::value {
display: table-cell;
}

Where this page came from

This page was imported from Wikibooks. From “XForms” on Wikibooks, by its contributors, under CC BY-SA 4.0. Changed here: set as a page; navigation and edit links left out; each image under its own licence, credited in its caption.

Nobody has written it yet — it is the source material at a new address, which is why search engines are asked to skip it and why no one earns from it. It is up for grabs: take it on, and it is yours to rewrite and to earn from.

Get each new page of

XForms

Following means one email when a page is added, nothing when a page changes.

Following means one email when a page is added, nothing when a page changes.

Comments

Spinner Logo

Next in XForms

CC BY-SA 4.0
XForms, Select and Group
CC BY-SA 4.0
*/ /* This line ensures all the separate input controls appear on their own lines */ xf|input, xf|select, xf|select1, xf|textarea {display:block; margin:5px 0;} /* Makes the labels right aligned in a 200px wide column that floats to the left of the input controls. */ xf|input > xf|label, xf|select >
CC BY-SA 4.0
Use the **xforms-value-changed** event to trigger a submission that puts possible values in a list. When the user select a value from the suggestion list it will replace the text value in the field. We will also add a bind rule so that the selection view will only be visible if there is at least one
CC BY-SA 4.0
The second select1 uses an **xf:itemset** to only select the relevant items from the second instance. In effect we are adding a "where" clause to the list of items selected in the second list. The presented form shows an example where the user can select a season (Spring, Summer,...) and in a second
CC BY-SA 4.0
The people will automatically be loaded into the form when the form loads. We will create triggers that will incrementally load the other portions of the model when they are needed. Each trigger will use a submission event that does a separate HTTP get to incrementally load data into a separate inst
CC BY-SA 4.0
விபரங்களை சரிப்பார்க்கவும்" sbutton="சேமி" cbutton="மீளமை" e1msg="கடவுச்சொல் தவறு!மீண்டும் உறுதிப்படுத்துக"> விண்ணப்பதாரர் பெயர் பிறந்த தேதி முகவரி விருப்பப்படும் நுழைவு பெயர் கைத் தொலைபேசி எண் தொலைபேசி எண் மின்னஞ்சல் முகவரி கடவுச்சொல் கடவுச்சொல் உறுதிப் படுத்து name="हिन्दी" rname="पंजीकरण फार्म" s