Content form tags

From GruppoZenit
Jump to: navigation, search

Content form tags are used to create forms in a webpage that allows users to fill some contents inside.


Contents

zcms:content-form

zcms:content-form tag is used to create forms. This tag can be used for inserting, updating and authentication. The components of the form such as textbox, textarea, password etc. can be added using the zcms:component tag. The supported attributes for this tag include:

Attribute Definition
name Name of the content form
type There can be of three types:
  1. INSERT – inserting new data
  2. UPDATE – updating the data
  3. AUTH – when form is used for authentication
action The action of the form
method The method of the form "get" or "post"


zcms:component

zcms:component tag stores information about creation of the components that constitutes the form such as text, password etc. The attributes of the tag include:

Attribute Definition
type There can be the following types:
  1. text – rendering text field in a form.
  2. textarea – rendering textarea field in a form.
  3. radio – rendering radio button in a form.
  4. select – rendering combo box in a form.
  5. filechooser – rendering file chooser in a form.
  6. checkbox – rendering checkboxes in a form.
  7. hidden – rendering a hidden field in form.
  8. password – rendering a password field in form.
  9. datacolumn – rendering an in-memory values to be inserted to a content model.
  10. date– rendering text field in form, a date type can be inserted to content model through this field.
name The name of the component. The name of the components should be same when using type radio, select and checkbox.
attribute This attribute defines the column in database where value is to be saved.
value This defines the value of the component type
path The path attribute is used by the file chooser component, which is the relative path where the file is to be saved
encrypt The value can be "true" or "false",Encrypt the password field. By default the value is true and all password saved will be encrypted.The encrypt can be used only with password component.
enc-type The encryption algorithm used or encryption. By default value is "MD5".

The values can be

  1. MD5
  2. SHA-1
  3. SHA-256
format The format in which the user enter the date ex:dd/MM/YYYY

zcms:captcha

zcms:captcha tag generates the captcha and the related items needed to validate a captcha.The captcha can be used inside zcms:content-form tag.The attributes of the tag include:

Attribute Definition
class defines style class for the captcha div.
length defines the length of captcha.
height defines the height of captcha image.
width defines the width of captcha image.
type defines the type of captcha
  1. NUMERIC - Generates numeric captcha.
  2. ALPHANUMERIC - Generates alphanumeric captcha.
  3. ALPHANUMERIC_UPPER - Generates alphanumeric captcha with uppercase letters.
  4. ALPHANUMERIC_LOWER - Generates alphanumeric captcha with lowercase letters.
  5. ALPHABETIC_UPPER - Generates captcha with uppercase alphabets.
  6. ALPHABETIC_LOWER - Generates captcha with uppercase alphabets.
error-message defines the error message to be shown.
holder-message defines the holder message for the textbox.
refresh-image defines the image for captcha refresh image.

zcms:submit

zcms:submit tag is used to submit a form. The link which is used to submit the form should be wrapped in this "submit" tag.

For
and the onclick property will be used for submission and for <a> the "href" attribute is used for form submit.

The tag can also be placed outside the zcms:content-form tag. The attributes of this tag include:

Attribute Definition
form The name of the form that should be submitted

zcms:validate

This tag is used to give validation to the form components. The message to be given on validation failure should be given inside the tag. The attributes of this tag include:

Attribute Definition
checkfor This attribute defines the type of validation to the field.

It includes

  1. required – makes component value mandatory.
  2. email – validates the email id.
  3. date – validates the date inside a component.
  4. compare - compares the component values against another value.
  5. required_checkbox_group – checks if at least one checkbox is checked in a group.
  6. required_radio_group – checks if any radio button is clicked among a group of radio buttons. It makes the selection mandatory of at least one button.
  7. duplicate – checks if the values in component is already inserted.
name The name of component to be validated
value This attribute is used to check the attribute against a value

zcms:status

zcms:status tag is used to define the status of one form. According to the status returned the action can be defined in this tag. The message to show on the event can be written inside the tag. The attributes of this tag includes:

Attribute Definition
event The event attribute can have 3 values
  1. SUCCESS – on successful submission of a form and authentication the success value is returned.
  2. ERROR – when some internal error occurs the event is returned.
  3. AUTH_FAILED – when the form is of "auth" type and the authentication fails this event is returned.
url This attribute defines to which URL the page should be redirected on a particular event.

Along with the URL the value of the id of the inserted data can also be passed to another page using "@@[id]" along with the URL. In addition with the last inserted id, the form input values can also be passed along with the URL by giving "@@[NAME]"


zcms:message

zcms:message tag defines the area where to show the error messages of the form components. The attributes for this tag includes:

Attribute Definition
for The attribute can have the value "*" or the name of the component.

“*” defines for all components the error message that should be shown in this area.


access-level

This tag is used along with zcms:content-form tag with type="AUTH", the level of the users can be retrieved using this tag. The tag supports the below listed attributes:

Attribute Definition
attribute The attribute name of the level defined for the users


Example: designing a form inside a webpage

Below it is written an example of how to create a form inside Z-CMS:

<zcms:content-form name="user" type="INSERT" action="saveuser" method="post">
Name:
   <zcms:component type="text" name="txtname" attribute="name" class="txt"/><br/>
Surname: 
   <zcms:component type="text" name="txtsurname" attribute="surname"/><br/>
Email:
   <zcms:component type="text" name="txtemail" attribute="email"/><br/>
password:
 <zcms:component type="password" attribute="password" encrypt="true" enc-type="SHA-1" /><br/>
Dob : 
    <zcms:component type="date" name="datepicker" attribute="dob" format="dd-yyyy-MM"/><br/> 
Sex:
   <zcms:component type="radio" name="radiosex" attribute="sex" value="M" />Male
   <zcms:component type="radio" name="radiosex" attribute="sex" value="F" />Female	
Photo: 
   <zcms:component type="filechooser" name="userphoto" attribute="user_photo"  path="biodata/photo/" />

<zcms:captcha class="captchaClass" length="5" height="70" width="200"  type="NUMERIC" error-message="enter captcha correctly" holder-message="enter char"  refresh-image="img/refreshButton.gif" />

   <zcms:validate checkfor="required" name="txtname">Please enter your name</zcms:validate>
   <zcms:status event="SUCCESS" url="community_welcome?name=@@[ txtname]">ok inviato</zcms:status>
   <zcms:status event="ERROR" url="#”>failed</zcms:status>

<zcms:message for="*" class="errorclass" />

</zcms:content-form>

See also

Personal tools
Namespaces

Variants
Actions
Toolbox