in reply to Re: Re: Magical SQL
in thread Magical SQL

I think this is good, in fact I've just done something like it, but with one extra feature: it is a class, so for a particular application it can be overriden. Here is the routine that makes an input field in a form:
# print an input element for a field, when replacing a record
sub replaceField {
    my ($this, $name, $value, $type, $isKey) = @_;

    # check for special handler in subclass
    my $h = "replace_$name";
    if ($this->can($h)) {
        $this->$h($name, $value, $type, $isKey);
		return
	};
	
    # default processing		
    my $attr = ''; # special attributes for tag
    if ('_' eq substr $name,0,1 ) {$attr .= 'READONLY ';};
    print qq($name: <input name="$name" class="$name" value="$value" $attr type="text" ></input>);
}