formVista(tm) Developers Guide and Reference
 

Chapter 7. Using Pre-Built formVista Components on a Web Page

Using pre-built components is very easy. You just have to set up your PHP enabled webpages with a few calls at various places and the framework takes care of the rest.

For this section, please refer to the formVista DemoShell component gallery. We will be referring to various examples there.

7.1. A Typical formVista PHP Page

Here is an example of a typical web page set up to host a single formVista component. For purposes of demonstration, it uses the “Complete Form” component from the Component Gallery.

<?php
// include the formVista processor and configuration generated
// by Configure.
include_once( "./config.php" );
// this component posts back to this page so the second 
// argument is NULL.
vistaLoad( "/fvml/form_complete", NULL  );
// if any components need to get data they do it now
vistaEvent( "GetData" );
// here components process any commands sent to them.
vistaProcessCmd();
?> 
<!-- your HTML begins here. -->
<HTML>
<HEAD>
<?php  
// style sheets needed by loaded components.
vistaEvent( "CSSIncludes" );
// javascript files needed by components.
vistaEvent( "JavascriptIncludes" );
?>
<!-- put your extra javascript includes or styles`heet
includes here -->
<SCRIPT LANGUAGE="javascript">
<?php 
// some components output custom javascript functions.
vistaEvent( "Javascript" ); 
?>
<!-- put any additional javascript calls you might want here -->
</SCRIPT>
</HEAD>
<!-- from here down it's just normal HTML with a few vista commands thrown in -->
<body bgcolor="#FFFFFF" marginheight="0" marginwidth="0" leftmargin="0" topmargin="0">
<table width="100%"> <tr> <td width="20%"> &nbsp; </td> <td valign="top">
<?php 
// this is where the component gets displayed.
vistaShow( "form_complete" );       
?>
<br> <br>
<?
// special event to handle divmenu components.
vistaEvent( "RenderSubmenus" );
// some tags like htmleditor need this event.
vistaEvent( "Footer" ); 
?>
</BODY>
</HTML>
  

This is all that's required to host any standard formVista component. This page will do the displaying of the form, the validation on submit, the dumping of data into the database and displaying feedback to the user.

Now we move on to describe each section of the page in more detail.

7.1.9. Rendering the component

To actually show the component or it's feedback if there is any, simply include:

<?
vistaShow("form_complete");
?>
   

at the point where you'd like the component to be displayed. The component will know whether or not it should display the component, a validation error or a feedback component.

7.1.10. Footer Events

The divmenu component, htmleditor tags and others need to do some processing at the end of the page. These two events are put before the closing body tag.

<?
// special event to handle divmenu components.
vistaEvent( "RenderSubmenus" );
// some tags needs this event.
vistaEvent( "Footer" ); 
?>