125 |
my $attr = $class->meta->get_attribute( $name ); |
my $attr = $class->meta->get_attribute( $name ); |
126 |
$attr_type = $attr->type_constraint->name if $attr->has_type_constraint; |
$attr_type = $attr->type_constraint->name if $attr->has_type_constraint; |
127 |
|
|
128 |
|
$value = $attr->default( $name ) if ! $value && $attr->has_default; |
129 |
|
|
130 |
if ( ref($config_params) eq 'HASH' ) { |
if ( ref($config_params) eq 'HASH' ) { |
131 |
$value = $config_params->{$name}; |
$value = $config_params->{$name}; |
132 |
} elsif ( ref($config_params) eq 'ARRAY' ) { |
} elsif ( ref($config_params) eq 'ARRAY' ) { |
137 |
} elsif ( $attr_type !~ m{^(Str|Int)$} ) { |
} elsif ( $attr_type !~ m{^(Str|Int)$} ) { |
138 |
$value_html = qq|<textarea name="$name" title="$attr_type">$value</textarea>|; |
$value_html = qq|<textarea name="$name" title="$attr_type">$value</textarea>|; |
139 |
} |
} |
140 |
$value = $attr->default( $name ) if ! $value && $attr->has_default; |
|
141 |
$label_title = qq| title="| . $attr->documentation . qq|"| if $attr->has_documentation; |
$label_title = qq| title="| . $attr->documentation . qq|"| if $attr->has_documentation; |
142 |
|
|
143 |
$default->{$name} = $value unless defined $default->{$name}; |
$default->{$name} = $value unless defined $default->{$name}; |
144 |
|
|
145 |
$value_html = qq|<input type="$type" name="$name" title="$attr_type" value="$value">| unless $value_html; |
if ( ! $value_html ) { |
146 |
|
my $suffix = ''; |
147 |
|
if ( $attr_type =~ m{^Bool$} ) { |
148 |
|
$type = 'checkbox'; |
149 |
|
$suffix = ' checked' if $value; |
150 |
|
} |
151 |
|
$value_html = qq|<input type="$type" name="$name" title="$attr_type" value="$value"$suffix>|; |
152 |
|
} |
153 |
|
|
154 |
# warn "# required $name ", $class->meta->get_attribute( $name )->dump( 2 ); |
# warn "# required $name ", $class->meta->get_attribute( $name )->dump( 2 ); |
155 |
$form .= qq|<label for="$name"$label_title>$label</label>| . $value_html; |
$form .= qq|<label for="$name"$label_title>$label</label>| . $value_html; |
156 |
} |
} |
157 |
my $html = qq|<h1>$class params</h1><form method="post">$form<input type="submit" value="Run $class"></form>|; |
my $html = qq|<h1>$class params</h1><form method="post">$form<input type="submit" value="Run $class"></form>|; |
158 |
push @{ $self->status }, { |
$self->add_status({ |
159 |
$self->editor( $self->class ) => { |
$self->editor( $self->class ) => { |
160 |
params => $self->params, |
params => $self->params, |
161 |
config_params => $config_params, |
config_params => $config_params, |
162 |
default => $default |
default => $default |
163 |
}, |
}, |
164 |
}; |
}); |
165 |
|
|
166 |
return ($html,$default) if wantarray; |
return ($html,$default) if wantarray; |
167 |
return $html; |
return $html; |