语法:
JForm规定根元素为<config>.在<config>元素下面有一个或者多个<fieldset>元素,每一个元素代表了一个HTML<fileset>,通常会将一组表单字段集合在一个<fieldset>中。<filedset>可以有一个可选的name属性,这个name属性可以用来定义这个字段组的名称,例如:<fieldset name="params">
每一个字段组必须包含一个或者多个<field>元素,每一个<filed>元素代表 了一个带有标签的表单字段。在joomla系统中,预定了一下标准的字段类型,我们可以直接使用。
下面看一下content组建的一个article.xml文件
<?xml version="1.0" encoding="utf-8"?> <form> <fieldset addfieldpath="/administrator/components/com_categories/models/fields" > <field name="id" type="text" class="readonly" label="JGLOBAL_FIELD_ID_LABEL" description ="JGLOBAL_FIELD_ID_DESC" size="10" default="0" readonly="true" /> <field name="asset_id" type="hidden" filter="unset" /> <field name="catid" type="categoryedit" label="JCATEGORY" description="JFIELD_CATEGORY_DESC" class="inputbox" required="true" > </field> <field name="buttonspacer" description="JGLOBAL_ACTION_PERMISSIONS_DESCRIPTION" type="spacer" /> <field name="created" type="calendar" label="COM_CONTENT_FIELD_CREATED_LABEL" description="COM_CONTENT_FIELD_CREATED_DESC" class="inputbox" size="22" format="%Y-%m-%d %H:%M:%S" filter="user_utc" /> <field name="created_by" type="user" label="COM_CONTENT_FIELD_CREATED_BY_LABEL" description="COM_CONTENT_FIELD_CREATED_BY_DESC" /> <field name="created_by_alias" type="text" label="COM_CONTENT_FIELD_CREATED_BY_ALIAS_LABEL" description="COM_CONTENT_FIELD_CREATED_BY_ALIAS_DESC" class="inputbox" size="20" /> <field name="modified" type="calendar" class="readonly" label="JGLOBAL_FIELD_MODIFIED_LABEL" description="COM_CONTENT_FIELD_MODIFIED_DESC" size="22" readonly="true" format="%Y-%m-%d %H:%M:%S" filter="user_utc" /> <field name="featured" type="list" label="JFEATURED" description="COM_CONTENT_FIELD_FEATURED_DESC" default="0" > <option value="0">JNO</option> <option value="1">JYES</option> </field> <field name="rules" type="rules" label="JFIELD_RULES_LABEL" translate_label="false" class="inputbox" filter="rules" component="com_content" section="article" validate="rules" /> </fieldset> </form>