rendered paste body<?php$form_open = "<form action=\"$url\" method=\"post\">\n";$form_close = "</form>\n";$tabs = "\t\t\t\t";$form_body = '';foreach( $form as $group => $inputs ){ $form_errors = ''; foreach( $errors as $error ) { $form_errors .= "\t\t<p class=\"error\">$error</p>\n"; } $form_body .= "\t<fieldset>\n". "\t\t<legend>$group</legend>\n". "\t\t<p class=\"warning\"><em>*</em> denotes required field.</p>\n". "$form_errors". "\t\t<ul>\n"; foreach( $inputs as $input ) { if( !isset($input->label) ) { $input->label = ucwords($input->name); } $required = ( isset($input->required) && $input->required = true ) ? '<em>*</em>' : ''; $label = "$tabs<label for=\"".$input->name."\">".$input->label."</label>$required\n"; $idname = 'name="'.$input->name.'" id="'.$input->name.'"'; $value = ( isset($input->value) ) ? ' value="'.$input->value.'"' : ''; $length = ( isset($input->length) && is_numeric($input->length) ) ? ' maxlength="'.$input->length.'"' : ''; $disabled = ( isset($input->disabled) && $input->disabled == true ) ? ' disabled="disabled"' : ''; $_input = ''; switch($input->type) { case 'hidden': $_input = "$tabs<input type=\"hidden\" $idname $value />\n"; break; case 'text': $_input = $label; $_input .= "$tabs<input type=\"text\" $idname $length$value$disabled />\n"; break; case 'password': $_input = $label; $_input .= "$tabs<input type=\"password\" $idname $length$disabled />\n"; break; case 'dropdown': $select = ( isset($input->selected) && $input->selected != false ) ? $input->selected : ''; $_input = $label; $_input .= "$tabs<select $idname $disabled>\n"; foreach( $input->options as $value => $name ) { $selected = ( (string)$value == (string)$select ) ? ' selected="selected"' : ''; $_input .= "\t$tabs<option value=\"$value\"$selected>$name</option>\n"; } $_input .= "$tabs</select>\n"; break; case 'textarea': $value = ( isset($input->value) ) ? $input->value : ''; $rows = ( isset($input->rows) ) ? ' rows="'.$inputs->rows.'" ' : ''; $cols = ( isset($input->cols) ) ? ' cols="'.$inputs->cols.'" ' : ''; $_input = $label; $_input .= "$tabs<textarea $idname $rows$cols$disabled>$value</textarea>\n"; break; case 'upload': $_input = $label; $_input .= "$tabs<input type=\"file\" $idname $disabled/>\n"; break; case 'checkbox': $checked = ( isset($input->checked) && $input->checked != false ) ? ' checked="checked" ' : ''; $_input = $label; $_input .= "$tabs<input type=\"checkbox\" $idname $value$checked$disabled />\n"; break; case 'submit': $_input = "$tabs<input type=\"submit\" $idname $value$disabled />\n"; break; } if( !empty($_input) ) { $form_body .= "\t\t\t<li>\n"; $form_body .= $_input; $form_body .= "\t\t\t</li>\n"; } } $form_body .= "\t\t</ul>\n"; $form_body .= "\t</fieldset>\n";}?><div class="form"><?= $form_open ?><?= $form_body ?><?= $form_close ?></div>