function actionDefault()
 {
     // Create the form
     $form = new YDForm('form1');
     $form->registerFilter('reverse', 'strrev');
     $form->setDefaults(array('txt2' => 'First text', 'txt3' => "2\nlines", 'hid1' => 'me hidden', 'chk1' => 'x', 'chk2' => false, 'sel1' => 2));
     $text =& $form->addElement('text', 'txt1', 'Enter text 1:');
     $text->_label = 'new label for txt1';
     $form->addElement('text', 'txt2', 'Enter text 2:', array('class' => 'textInputClass', 'name' => 'x'));
     $form->addElement('textarea', 'txt3', 'Enter text 2:');
     $form->addElement('textareacounter', 'txtcounter_1', 'Textarea counter 1', array(), array('maxlength' => 10, 'before' => ' (', 'after' => ' characters remaining)'));
     $form->addElement('textareacounter', 'txtcounter_2', 'Textarea counter 2');
     $form->addElement('radio', 'rad1', 'Select a value 1:', array(), array(1 => 'een', 2 => 'twee'));
     $form->addElement('radio', 'rad2', 'Select a value 2:', array(), array(1 => 'een<br/>', 2 => 'twee'));
     $form->addElement('hidden', 'hid1', '');
     $form->addElement('hidden', 'hid2', '', array(), 'i am also hidden');
     $form->addElement('image', 'img1', '', array(), 'http://www.scripting.com/images/xml.gif');
     $form->addElement('password', 'pas1', 'Enter your password');
     $form->addElement('bbtextarea', 'bbt1', 'Enter your BBCode');
     $form->addElement('checkbox', 'chk1', 'Select me please');
     $form->addElement('checkbox', 'chk2', 'Select me please');
     $form->addElement('select', 'sel1', 'Select an option:', array(), array(1 => 'een', 2 => 'twee'));
     $form->addElement('span', 'span1', 'This is a span. The next element is an image (img).');
     $form->addElement('img', 'img2', 'http://www.scripting.com/images/xml.gif');
     $form->addElement('file', 'fil1', 'Select an file:');
     $form->addElement('submit', 'cmd1', 'Send');
     $form->addElement('reset', 'res1', 'Reset');
     $form->addFilter('__ALL__', 'upper');
     $form->addFilter('txt1', 'trim');
     $form->addFilter('txt2', 'reverse');
     $form->addRule('txt1', 'required', 'txt1 is required');
     $form->addRule('chk2', 'exact', 'chk2 is required', 1);
     $form->addFormRule(array(&$this, 'formrule'), 'txt1 is required');
     if (YDConfig::get('YD_DEBUG') == 1 || YDConfig::get('YD_DEBUG') == 2) {
         YDDebugUtil::dump($form->_regElements, 'Registered elements');
         YDDebugUtil::dump($form->_regRules, 'Registered rules');
         YDDebugUtil::dump($form->_regFilters, 'Registered filters');
         YDDebugUtil::dump($form->_filters, 'Filters');
         YDDebugUtil::dump($form->_rules, 'Rules');
         YDDebugUtil::dump($form->_formrules, 'Form Rules');
         YDDebugUtil::dump($form->getValue('txt1'), 'txt1');
         YDDebugUtil::dump($form->getValue('txt2'), 'txt2');
         YDDebugUtil::dump($_POST, '$_POST');
         YDDebugUtil::dump($_FILES, '$_FILES');
         YDDebugUtil::dump($form->toArray());
     }
     if ($form->validate()) {
         YDDebugUtil::dump($form->getModifiedValues(), 'Form modified values');
         YDDebugUtil::dump($form->getValues(), 'Form values');
     } else {
         $form->display();
     }
     // Create the form
     $form2 = new YDForm('form2');
     $form2->setDefaults(array('txt1' => 'First text'));
     $form2->addElement('text', 'txt1', 'Enter text 1:');
     $form2->addElement('text', 'txt2', 'Enter text 2:');
     $form2->addElement('submit', 'cmd1', 'Send');
     $form2->display();
 }
 function actionDefault()
 {
     // Create the form
     $form = new YDForm('form1');
     $form->addElement('text', 'text1', 'Enter text 1:');
     $form->addElement('text', 'text2', 'Enter text 2:');
     $form->addElement('textarea', 'textarea', 'Enter text 3:');
     $form->addElement('radio', 'radio1', 'Select a value 1:', array(), array(1 => 'one', 2 => 'two'));
     $form->addElement('radio', 'radio2', 'Select a value 2:', array(), array(1 => 'one', 2 => 'two'));
     $form->addElement('hidden', 'hidden1', '');
     $form->addElement('hidden', 'hidden2', '', array(), 'i am also hidden');
     $form->addElement('image', 'image', '', array(), 'http://www.scripting.com/images/xml.gif');
     $form->addElement('password', 'password', 'Enter your password');
     $form->addElement('bbtextarea', 'bbtextarea', 'Enter your BBCode');
     $form->addElement('checkbox', 'checkbox1', 'Check me 1');
     $form->addElement('checkbox', 'checkbox2', 'Check me 2');
     $form->addElement('select', 'select', 'Select an option:', array(), array(1 => 'one', 2 => 'two'));
     $form->addElement('dateselect', 'dateselect', 'Select a date:');
     $form->addElement('datetimeselect', 'datetimeselect', 'Select a date:');
     $form->addElement('timeselect', 'timeselect', 'Select a date:');
     $form->addElement('file', 'file', 'Select an file:');
     $form->addElement('submit', 'submit', 'Send');
     $form->addElement('button', 'button', 'Button');
     $form->addElement('reset', 'resest', 'Reset');
     $form->setDefaults(array('radio1' => 1, 'radio2' => 2, 'text1' => 'my text one', 'select' => 1, 'checkbox1' => 'on'));
     if ($form->validate()) {
         YDDebugUtil::dump($form->getDefaults(), 'Form default values');
         YDDebugUtil::dump($form->getModifiedValues(), 'Form modified values');
         YDDebugUtil::dump($form->getValues(), 'Form values');
     } else {
         $form->display();
     }
 }