DOFormBuilder :: useForm problems
| From: | Alexander Petri | Date: | Fri, 05 Nov 2004 16:55:44 +0000 |
| Subject: | DOFormBuilder :: useForm problems | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-15355@lists.php.net to get a copy of this message | ||
again i tried to make different forms for one DO
and failed.
i.e i tried to make a custom Form
but the FB renders two nearly same forms
the first one is from my CustomFormClass
and the second is rendered from the default FB
so i tried to switch
$builder->useForm($form,true);
$builder->useForm($form,false);
but the only thing that happens was
the switching my CustomForm over or under
the default Form
how can i make that the default Form does not appear
and(!!!) the Form works!
heres my code
/////////////////////////////////////////////////////////////////////////
// Application code:
$do = DB_DataObject::factory('news');
$do->get($news_id);
$builder =& DB_DataObject_FormBuilder::create($do);
$form = new CustomForm();
$builder->useForm($form);
$form =& $builder->getForm();
/////////////////////////////////////////////////////////////
// Class Code
class CustomForm extends HTML_QuickForm {
function CustomForm($formName='CustomerForm',$method='post',
$action='',$target='_self', $attributes=null) {
parent::HTML_QuickForm($formName, $method, $action, $target,
$attributes,true);
$this->addElement('header','ha','News ändern');
$nr[0]="Normaler Bereich";
$nr[1]="Privater Bereich";
$this->addElement('hidden','id');
$this->addElement('select', 'news_status','News Kategorie',$nr);
$this->addElement('text', 'news_headline', 'Headline');
$this->addElement('text', 'news_subheadline', 'subheadline');
$this->addElement('text', 'news_text', 'Text:');
//$this->addElement('text', 'nachname', 'Nachname');
$this->addElement('submit', 'submit', 'Speichern');
$this->applyFilter('__ALL__', 'trim');
$this->addRule('news_headline','Bitte Headline
eingeben','required');
$this->addRule('news_headline','Headline zu
kurz!','minlength',6);
$this->addRule('news_headline','Headline zu
lang!','maxlength',255);
$this->addRule('news_subheadline','Subeadline zu
kurz!','minlength',6);
$this->addRule('news_subheadline','Subeadline zu
lang!','maxlength',255);
$this->addRule('news_text','Bitte Text eingeben','required');
$this->addRule('news_text','Text zu kurz!','minlength',6);
}
}