templating inside a generated form helps creating complex form layouts

template

An element type to reorganize your form layout.

It's a template (or a container) for displaying any other form elements grouped together. A great way to

  • group together title - first name - lastname fields in one form row (by removing table tags from the rowlayout of these elements and display them in a template)
  • build special layouts like this:

As this element only affects form layout, there's no returned value by $clonefish->getElementValues() or other getter methods.


<?php

$config 
= Array(
  
'id' => Array(
    
'type'           => 'template',
    
'displayname'    => 'Some fields reorganized',
    
'value'          => 
      
'<table>' .
      
'%newslettercheckbox%' 
      
'%confirmcheckbox%' 
      
'%marketingcheckbox%' 
      
'</table>',
    
'inheriterrors'  => 0,
    
// "inherit" errors from included elements: this way the 
    // template element row will be styled using errorstyle when
    // validation fails on the server side for some element
    // included in the template.

    
'rowlayout'      => '...%element% %prefix% %postfix% etc...',
    
'prefix'         => 'string to display before element',
    
'postfix'        => 'string to display after element',
    
'display'        => 0,
  )
);

// This setting assumes that the elements called 
// newslettercheckbox,
// confirmcheckbox,
// marketingcheckbox are already defined, 
// and they have inherited the form 'element' layout setting 
// of a tabular form layout, which is a table row.

?>


Live examples:

form validation for developers!

clonefish is a proven, mature form generator class that helps PHP developers to create, validate and process secure, flexible and easy-to-maintain forms
learn more
Bookmark and Share