[Jifty-commit] r1739 - jifty/trunk/lib/Jifty/Web/Form
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Thu Aug 3 02:17:01 EDT 2006
Author: clkao
Date: Thu Aug 3 02:16:55 2006
New Revision: 1739
Modified:
jifty/trunk/lib/Jifty/Web/Form/Clickable.pm
Log:
Form::Clickable: Don't mix self accessors and args.
Modified: jifty/trunk/lib/Jifty/Web/Form/Clickable.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web/Form/Clickable.pm (original)
+++ jifty/trunk/lib/Jifty/Web/Form/Clickable.pm Thu Aug 3 02:16:55 2006
@@ -128,48 +128,50 @@
sub new {
my $class = shift;
- my $self = bless {}, $class;
-
my ($root) = $ENV{'REQUEST_URI'} =~ /([^\?]*)/;
- my %args = (
- url => $root,
- label => 'Click me!',
- tooltip => '',
+ my $self = bless {
class => '',
+ label => 'Click me!',
+ url => $root,
escape_label => 1,
+ tooltip => '',
continuation => Jifty->web->request->continuation,
submit => [],
preserve_state => 0,
+ }, $class;
+
+ my %args = (
parameters => {},
as_button => 0,
as_link => 0,
@_,
);
+
$args{render_as_button} = delete $args{as_button};
$args{render_as_link} = delete $args{as_link};
$self->{parameters} = {};
+ for my $field ( $self->accessors() ) {
+ $self->$field( $args{$field} ) if exists $args{$field};
+ }
+
for (qw/continuation call/) {
- $args{$_} = $args{$_}->id if $args{$_} and ref $args{$_};
+ $self->{$_} = $self->{$_}->id if $self->{$_} and ref $self->{$_};
}
- if ( $args{submit} ) {
- $args{submit} = [ $args{submit} ] unless ref $args{submit} eq "ARRAY";
- $args{submit}
- = [ map { ref $_ ? $_->moniker : $_ } @{ $args{submit} } ];
+ if ( $self->{submit} ) {
+ $self->{submit} = [ $self->{submit} ] unless ref $self->{submit} eq "ARRAY";
+ $self->{submit}
+ = [ map { ref $_ ? $_->moniker : $_ } @{ $self->{submit} } ];
# If they have an onclick, add any and all submit actions to the onclick's submit list
- if ($args{onclick}) {
- $args{onclick} = [ (ref $args{onclick} eq "ARRAY" ? @{ $args{onclick} } : $args{onclick}), map { submit => $_ }, @{$args{submit}} ];
+ if ($self->{onclick}) {
+ $self->{onclick} = [ (ref $self->{onclick} eq "ARRAY" ? @{ $self->{onclick} } : $self->{onclick}), map { submit => $_ }, @{$self->{submit}} ];
}
}
- for my $field ( $self->accessors() ) {
- $self->$field( $args{$field} ) if exists $args{$field};
- }
-
# Anything doing fragment replacement needs to preserve the
# current state as well
if ( grep { $self->$_ } $self->handlers or $self->preserve_state ) {
More information about the Jifty-commit
mailing list