IText

From FiFormsWiki

Jump to: navigation, search

iText creates a simple, data-bound text input on a form. It is represented by the <iText /> element in FiForms XML.

Contents

XML iText

The iText element and attributes are documented at http://xml.fiforms.org/schema/12/doc/FiForm.html#element_iText

The following example is a typical representation of iText in an XML form definition:

<iText field="FIRST_NAME" caption="Addressee's First Name" size="40"  />

Some of the most relevant attributes of this element include:

  • field: The name of the field in the database
  • caption: The field label on the form
  • size: Width of the field, in characters
  • maxlength: The maximum number of characters allowed
  • default: default value
  • readonly: Makes the field read-only if this attribute is set to "readonly"
  • required: If yes, then a value is required in this field.

Regular Expression input validation and input/output mangling (see Input Processing with Regular Expressions).

  • formatexp: Regular Expression used to validate input
  • formaterror: Used with formatexp to provide sensible error messages.
  • displaymatch: Regular Expression to match on converting from database value to displayed value
  • displayformat: Value to replace with on converting from database value to displayed value
  • inputmatch: Regular Expression to match on converting from displayed value to database value
  • inputformat: Value to replace with on converting from displayed value to database value
  • transform: Transform text to uppercase or lowercase

Dynamically Loading Data

The iText element can contain <loaddata /> and <depends /> elements for dynamically filling the data from the server using AJAX. For example, suppose you have a form to create a sales receipt. You have a dropdown box (iDBSelect)bound to a field named CATALOG_ID in the receipt form. Then you have an iText (or more perhaps iNumber) field bound to SALE_PRICE. You want the software to automatically update the sale price whenever an item is selected from the dropdown box. You would create the form something like this:

...

<iDBSelect caption="Catalog Item" field="CATALOG_ID" rowQuery="SELECT CATALOG_ID, CATALOG_DESC FROM catalog" />

<iText caption="Price" field="SALE_PRICE">
   <loaddata>get_price.xml</loaddata>
   <depends>CATALOG_ID</depends>
</iText>

...

Then, create the file get_price.xml in the reports folder (NOT the forms folder), like this:

<reportdef xmlns="http://xml.fiforms.org/FiForms/" version="1.1">
 <title>List Books by Category</title>
 <connect db="fiforms_sample" />
 <param name="CATALOG_ID" />
 <query>
   <sql>

     SELECT CATALOG_PRICE FROM catalog WHERE CATALOG_ID="%CATALOG_ID%"

   </sql>
 </query>
</reportdef>

PHP Implementation

The following information describes the internal PHP Implementation of the iText element. This information may be somewhat outdated--the best source of implementation details is the actual source code.

Class Properties

class iText extends iInput


$size The size of the text input, echoed to the output as size="%size%". Default is 20.
$type The type of text input. This is simply echoed to the output as type="%type%". Default is "text".


Properties inherited from iInput: $caption $currentRec $dbField $error $errorMsg $formatStr $formatStrRO $otherTags $readOnly $section $value $valueToSave

Method Detail

Methods inherited from iInput

  • checkRO
  • drawInput
  • getValueToSave
  • hide
  • iInput
  • throwError


iText

Constructs a new iText object.

Syntax: iText($dbField,$caption)


Parameters

$dbField - Name of bound database field

$caption - (optional) Field caption. If omitted, set to the dbField name.

Examples

Example


Declaring a simple iText on a form

  $frm->inputs[] = new iText('FName','First Name');
Returns

A new iText object

Personal tools