Mercurial > pub > Impl
diff Lib/IMPL/Web/TT/Form.pm @ 126:c8dfbbdd8005
Several bug fixes
Forms support pre-alfa version
author | wizard |
---|---|
date | Fri, 11 Jun 2010 04:29:51 +0400 |
parents | e30bdd040fe3 |
children | 0dce0470a3d8 |
line wrap: on
line diff
--- a/Lib/IMPL/Web/TT/Form.pm Thu Jun 10 17:43:51 2010 +0400 +++ b/Lib/IMPL/Web/TT/Form.pm Fri Jun 11 04:29:51 2010 +0400 @@ -7,7 +7,7 @@ use IMPL::DOM::Navigator::SchemaNavigator; use IMPL::DOM::Property qw(_dom); -__PACKAGE__->PasssThroughArgs; +__PACKAGE__->PassThroughArgs; BEGIN { public property base => prop_all; @@ -26,22 +26,53 @@ die new IMPL::InvalidOperationException('Can\'t find a form definition in a schema',$this->nodeName,$this->base) unless $this->schema->selectNodes(sub { $_->nodeName eq 'ComplexNode' and $_->name eq $this->base }); + + $this->errors([]) unless $this->errors; } -sub createControl { - my ($this, $path, $class, $hashArgs) = @_; +sub makeControlArgs{ + my ($this,$path) = @_; my $navi = new IMPL::DOM::Navigator::SchemaNavigator($this->schema); + my @path = ($this->base, split /\./,$path); - $navi->NavigateName($_) or die new IMPL::InvalidAgrumentException( + $navi->NavigateName($_) or die new IMPL::InvalidArgumentException( "Can't find a definition for an element", $_, $path, - $this->element - ) foreach $this->base, split /\./,$path; + $this->element, + ) foreach @path; my $schema = $navi->Current; - my @errors = grep $_->Source == $navi->SourceSchemaNode + my $node = $this->data->selectSingleNode(@path); + + my @errors; + + if ($node) { + @errors = grep { ( $_->Node || $_->Parent) == $node } @{$this->errors}; + } + + return { + schema => $schema, + sourceSchema => $navi->SourceSchemaNode, + errors => \@errors, + data => $node, + formParameter => join '/', @path + }; +} + +sub formErrors { + my ($this) = @_; + + if (my $node = $this->data->selectSingleNode($this->base) ) { + return [ + grep { + ( $_->Node || $_->Parent) == $node + } @{$this->errors} + ]; + } else { + return []; + } }