Code:
// Formular aufbauen
$objForm = new \Haste\Form\Form('FORM_ID','POST', function ($objHaste)
{
return \Input::post('FORM_SUBMIT') === $objHaste->getFormId();
});
$objForm->addFormField('suchbegriff',array(
'label' => 'Suchbegriff',
'inputType' => 'text',
'value' => \Input::post('suchbegriff'),
'eval' => array( 'maxlength'=>50, 'rgxp' => 'extnd', 'minlength' => 3)
));
$objForm->addFormField('kategorie',array(
'label' => 'Berufskategorie',
'inputType' => 'select',
'value' => \Input::post('kategorie'),
'options' => array(
'Vertrieb/Marketing' => 'Vertrieb/Marketing',
'Kaufmännische Berufe' => 'Kaufmännische Berufe',
'Technische Berufe' => 'Technische Berufe',
'IT' => 'IT'
),
'eval' => array( 'includeBlankOption' => true, 'blankOptionLabel' => '-- bitte auswählen --' )
));
$objForm->addFormField('arten',array(
'label' => 'Stellenarten',
'inputType' => 'radio',
'value' => \Input::post('arten'),
'options' => array(
'' => 'Alle anzeigen',
'Vollzeit' => 'Vollzeit',
'Teilzeit' => 'Teilzeit',
'Interim' => 'Interim'
),
'eval' => array()
));
$objForm->addFormField('ort',array(
'label' => 'Ort / Region / PLZ',
'inputType' => 'text',
'value' => \Input::post('ort'),
'eval' => array( 'maxlength'=>50, 'rgxp' => 'extnd' )
));
$objForm->addFormField('umkreis',array(
'label' => 'Oder im Umkreis von',
'inputType' => 'text',
'value' => \Input::post('umkreis'),
'eval' => array( 'maxlength'=>5, 'rgxp' => 'natural', 'class' => 'inline border' , 'placeholder' => 'km' )
));
$objForm->addFormField('umplz',array(
'label' => 'um die PLZ',
'inputType' => 'text',
'value' => \Input::post('umplz'),
'eval' => array( 'maxlength'=>5, 'rgxp' => 'natural', 'class' => 'inline' )
));
$objForm->addSubmitFormField('submit','Suchen');
if ($objForm->validate() === true) {
$arrData = $objForm->fetchAll();
// Schreibe die Änderungen zurück in die DB / Model u.s.w.
}
// Variablen an das Template Übergeben
$this->Template->form = $objForm->generate(); // Das generierte Formular an das Template übergeben
Viel Spass beim ausprobieren.
Lesezeichen