ValidForm Builder

Easy and safe XHTML 1.0 strict forms with validation!

Contents

VF_Select→addGroup

VF_Select→addGroup — Adds a new option to the current select list


Description

addGroup (string $label);

Adds a new field object to the current object.


Parameters

  • label
    The label for the optgroup element

Return values

Returns a new VF_SelectGroup object.

Examples

//*** This is what we had so far.
$objSelectList = $objForm->addField("support-type", "Support type", VFORM_SELECT_LIST,
        array(
                "required" => true
        ),
        array(
                "required" => "You must select a support type."
        ),
        array(
                "tip" => "If you're not sure, just choose 'no support'."
        )
);
        //*** This is where the magic happens.
        // The default value needs to be empty in order to do a 'required' check.
        $objSelectList->addField("Select support type", "", true); 
        // In HTML this looks like: <option value="tech">Tech support</option>
        $objSelectList->addField("Tech support", "tech"); 

//*** This is where we insert a new select group object
$objNewGroup = $objSelectList->addGroup("Some other options");
        $objNewGroup->addField("Friendly support", "friendly");
        $objNewGroup->addField("No support", "no-support");