$element = new Varien_Data_Form_Element_Text(); $element->setId('username'); $element->setName('username'); $element->setLabel('Username:'); echo $element->getLabel();
$element = new Varien_Data_Form_Element_Select(); $element->setId('country'); $element->setName('country'); $element->setLabel('Country:'); $options = array( 'usa' => 'United States', 'uk' => 'United Kingdom', 'can' => 'Canada' ); $element->setOptions($options); echo $element->getLabel();In this example, a new select element is created with an ID and name of "country". The label for this element is set as "Country:", and options for the select element are added using the setOptions method. The getLabel method is then called to retrieve the HTML label. Both of these examples are part of the Varien package library, which is a PHP library used by Magento for creating and managing data objects.