function text_field($params, $name, $label = null, $label2 = null, $attrs = null) { $val = param_value($params, $name); $id = field_name_to_id($name); ?> <div class="field"> <?php if ($label) { ?> <label for="<?php esc($id); ?> "> <?php esc($label); if ($label2) { ?> <span class="label-extra">(<?php esc($label2); ?> )</span> <?php } ?> </label> <?php } ?> <input type="text" id="<?php esc($id); ?> " name="<?php esc($name); ?> " value="<?php esc($val); ?> " <?php print_attrs($attrs); ?> /> </div> <?php }
function param_email($scope, $name, $required = false, $default = '') { $value = param_value($scope, $name, $required, null); if (is_null($value)) { if ($required) { throw new Exception("参数'{$name}'必须提供", 400); } return $default; } if (is_email($value)) { return $value; } throw new Exception("参数'{$name}'必须为浮点数类型", 500); }