function show_form_field($data, $errors, $type, $name, $label, $options = array()) { $id = str_replace(array('[', ']'), '_', $name); if (isset($errors[$id]) and $errors[$id]) { echo '<div class="field field-has-errors field-' . htmlspecialchars($id . ($options['field_class'] ? ' ' . $options['field_class'] : '')) . '">'; echo '<ul class="field-error-list">'; foreach ($errors[$id] as $err) { echo '<li>' . htmlspecialchars($err) . '</li>'; } echo '</ul>'; } else { echo '<div class="field field-' . htmlspecialchars($id . ($options['field_class'] ? ' ' . $options['field_class'] : '')) . '">'; } if (isset($data[$name]) and $data[$name]) { $options['value'] = $data[$name]; } if ($label) { show_form_label($name, $label . ' :'); } switch ($type) { case 'input': show_form_input($name, $options); break; case 'textarea': show_form_textarea($name, $options); break; case 'select': show_form_select($name, $options); break; } echo '</div>'; }
function nysts($ntext, $ytext, $finame, $default = '', $fa, $ext) { $qy_value[] = ""; $qy_option[] = "请选择"; $par = array(array('Y', $ytext), array('N', $ntext)); if ($fa == 1) { $mrStr = "<option value=''>请选择</option>"; if (is_array($par)) { foreach ($par as $stemp) { $selc = $default == $stemp[0] ? 'selected' : ''; $mrStr .= "<option value='" . $stemp[0] . "' {$selc}>" . $stemp[1] . " </option>"; } } } else { if (is_array($par)) { foreach ($par as $qv) { $qy_value[] = $qv[0]; $qy_option[] = $qv[1]; } } $_REQUEST[$finame] = $default == '' ? $_REQUEST[$finame] : $default; $mrStr = show_form_select($qy_value, $qy_option, $finame, $_REQUEST[$finame], $ext); } return $mrStr; }