input type=radio, sql database radio button group

inputRadioDynamic

Identical to inputRadio, but taking its options not only from the 'value' field, but also from the results of a database query.


<?php

$config 
= Array(
  
'id' => Array(
    
'type'           => 'inputRadioDynamic',
    
'displayname'    => 'This is a dynamic radio button collection',

    
// first field is the option value, second is the displayed 
    // option text, field names do not count
    
'sql'            => 'SELECT id, name FROM categories'

    
'values'         => Array( => 'choose nothing' ),
    
'value'          => '0',

    
// layout: the container for the entire radio group
    
'layout'         => '%s',

    
// itemlayout: the layout of a radio row
    
'itemlayout'     => '%radio% %label%\n',

    
// divider settings: to create multiple columns
    
'divide'         => 5// default: null
    
'divider'        => ''// default: '', see example!

    
'html'           => 'class="inputfieldstyle"',
    
'help'           => 'validation failed for this element',
    
'rowlayout'      => '...%element% %prefix% %postfix% etc...',
    
'prefix'         => 'string to display before element',
    
'postfix'        => 'string to display after element',
    
'readonly'       => 0,
    
'display'        => 0
  
)

);

?>


Live examples:

Validators to use together with this element:

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