/[Frey]/trunk/lib/Frey/Action.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/Frey/Action.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 369 by dpavlin, Mon Nov 17 14:37:48 2008 UTC revision 372 by dpavlin, Mon Nov 17 15:42:12 2008 UTC
# Line 97  sub params_form { Line 97  sub params_form {
97          my $html = qq|<h1>$class params</h1><form method="post">|;          my $html = qq|<h1>$class params</h1><form method="post">|;
98    
99          foreach my $name ( grep { ! $class->meta->get_attribute($_)->is_lazy } $self->attributes ) {          foreach my $name ( grep { ! $class->meta->get_attribute($_)->is_lazy } $self->attributes ) {
100                    my $attr_type;
101                  my $type = $name =~ m/^pass/ ? 'password' : 'text';                  my $type = $name =~ m/^pass/ ? 'password' : 'text';
102                    my $label = $name;
103                  my $value = '';                  my $value = '';
104                    my $label_title = '';
105                  my $value_html = '';                  my $value_html = '';
106                  if ( ref($params) eq 'HASH' ) {                  if ( ref($params) eq 'HASH' ) {
107                          $value = $params->{$name};                          $value = $params->{$name};
# Line 110  sub params_form { Line 113  sub params_form {
113                                  } @$params                                  } @$params
114                          ) . qq|</select>|;                          ) . qq|</select>|;
115                  } elsif ( my $attr = $class->meta->get_attribute( $name ) ) {                  } elsif ( my $attr = $class->meta->get_attribute( $name ) ) {
116                          if ( $attr->has_type_constraint && $attr->type_constraint->can('values') ) {                          $attr_type = $attr->type_constraint->name;
117                                  $value_html = qq|<select name="$name">| . join("\n",                          if ( $attr->has_type_constraint ) {
118                                          map { qq|<option value="$_">$_</option>| } @{ $attr->type_constraint->values }                                  if ( $attr->type_constraint->can('values') ) {
119                                  ) . qq|</select>|;                                          $value_html = qq|<select name="$name">| . join("\n",
120                          } elsif ( $attr->has_default ) {                                                  map { qq|<option value="$_">$_</option>| } @{ $attr->type_constraint->values }
121                                  $value = $attr->default( $name );                                          ) . qq|</select>|;
122                                    } elsif ( $attr_type !~ m{^(Str|Int)$} ) {
123                                            $value_html = qq|<textarea name="$name" title="$attr_type">$value</textarea>|;
124                                    }
125                          }                          }
126                            $value = $attr->default( $name ) if ! $value && $attr->has_default;
127                            $label_title = qq| title="| . $attr->documentation . qq|"| if $attr->has_documentation;
128                  } else {                  } else {
129                          warn "wired attribute $name";                          warn "wired attribute $name";
130                  }                  }
131                  $value_html = qq|<input type="$type" name="$name" value="$value">| unless $value_html;  
132                    $value_html = qq|<input type="$type" name="$name" title="$attr_type" value="$value">| unless $value_html;
133    
134  #               warn "# required $name ", $class->meta->get_attribute( $name )->dump( 2 );  #               warn "# required $name ", $class->meta->get_attribute( $name )->dump( 2 );
135                  $html .= qq|<label for="$name">$name</label>| . $value_html;                  $html .= qq|<label for="$name"$label_title>$label</label>| . $value_html;
136          }          }
137          $html .= qq|<input type="submit" value="Run $class"></form>|;          $html .= qq|<input type="submit" value="Run $class"></form>|;
138    

Legend:
Removed from v.369  
changed lines
  Added in v.372

  ViewVC Help
Powered by ViewVC 1.1.26