u mnie generowanie formularza wyglada tak:
<?php
$oForm = new Form
( array( 'name' => 'test', 'action' => '#', 'method' => 'post') ); $oFieldset = new Fieldset
( array( 'style' => '-moz-border-radius: 6px;' ) ); $oLegend = new Legend();
$oLegend->setText( 'Logowanie' );
$oFieldset->addElement( $oLegend );
$oLoginLabel = new Label
( array( 'for' => 'login' ) ); $oLoginLabel->setText( 'Login:' );
$oFieldset->addElement( $oLoginLabel );
$oLogin = new Input
( array( 'id' => 'login', 'name' => 'login', 'type' => 'text' ) ); $oForm->addPlugin( new IsNotNullRule( $oLogin ) );
$oFieldset->addElement( $oLogin );
$oPassLabel = new Label
( array( 'for' => 'password' ) ); $oPassLabel->setText( 'Haso:' );
$oFieldset->addElement( $oPassLabel );
$oPass = new Input
( array( 'id' => 'password', 'name' => 'pass', 'type' => 'text' ) ); $oForm->addPlugin( new IsNotNullRule( $oPass ) );
$oForm->addPlugin( new MD5Hash( $oPass ) );
$oFieldset->addElement( $oPass );
$oFieldset->addElement( new Input
( array( 'id' => 'submitBtn', 'type' => 'submit', 'value' => 'Wyslij' ) ) ); $oForm->addElement( $oFieldset );
$sContent = '';
if( $oContext->getRequest()->getMethod() == IHttpRequest::POST )
{
echo $oForm->processPlugins() ?
'formularz wypelniony poprawnie' : 'formularz wypeniony niepoprawnie.'; }
$oContext->getResponse()->addContent( $sContent . $oForm->getCode() );
?>
moze wydaje sie ze duzo kodu ale po pierwsze masz trutaj tez fieldset i labele po drugie dosyc wygodnie sie pisze
Cytat
Na poczatek chcialem ograniczyc dodawanie parametrow do tych ktore sa "akceptowane" przez klase, tak aby uzytkownik nie podal nieistniejacego parametru.
ja nawet to zaimplementowałem i wyszło że wyrzera pamięc (uzywalem array_diff) wiec nie warto;]