[Jifty-commit] jifty branch, master, updated. jifty-1.01209-12-g18f5b11

Jifty commits jifty-commit at lists.jifty.org
Fri Jan 21 17:06:35 EST 2011


The branch, master has been updated
       via  18f5b117edb2bc62d705a4dcb395123dfa0158ad (commit)
      from  ffc70e996c86c9c7496c9e5f2b5dbd5a23aad3eb (commit)

Summary of changes:
 lib/Jifty/Web/Form.pm |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)

- Log -----------------------------------------------------------------
commit 18f5b117edb2bc62d705a4dcb395123dfa0158ad
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Fri Jan 21 17:00:09 2011 -0500

    Add the id and class attributes to Forms, aliasing id and name

diff --git a/lib/Jifty/Web/Form.pm b/lib/Jifty/Web/Form.pm
index 7d69e4c..9865ecd 100644
--- a/lib/Jifty/Web/Form.pm
+++ b/lib/Jifty/Web/Form.pm
@@ -5,7 +5,10 @@ package Jifty::Web::Form;
 
 use base qw/Jifty::Object Class::Accessor::Fast/;
 
-__PACKAGE__->mk_accessors(qw(actions printed_actions name call is_open disable_autocomplete target submit_to onsubmit));
+__PACKAGE__->mk_accessors(qw(actions printed_actions name call is_open disable_autocomplete target submit_to onsubmit class));
+
+# Alias id to name
+*id = *name;
 
 use Scalar::Util qw/weaken/;
 
@@ -21,6 +24,15 @@ Creates a new L<Jifty::Web::Form>.  Arguments:
 
 =over
 
+=item id
+
+The HTML id attribute given to the form.  This is aliased to L<name>.  That is,
+name and id are always equal and changing one changes the other.
+
+=item class
+
+The HTML class attribute given to the form.
+
 =item name
 
 The name given to the form.  This is mostly for naming specific forms
@@ -205,6 +217,8 @@ sub start {
 
     my $form_start = qq!<form method="post" action="!  . Jifty->web->escape( $root ) . qq!"!;
     $form_start .= qq! name="@{[ $self->name ]}"! if defined $self->name;
+    $form_start .= qq! id="@{[ $self->name ]}"! if defined $self->name; # always the same as name
+    $form_start .= qq! class="@{[ $self->class ]}"! if defined $self->class;
     $form_start .= qq! target="@{[ $self->target ]}"! if defined $self->target;
     $form_start .= qq! autocomplete="off"!  if defined $self->disable_autocomplete;
     $form_start .= qq! onsubmit="! .Jifty->web->escape( $self->onsubmit ). qq!"!  if defined $self->onsubmit;

-----------------------------------------------------------------------


More information about the Jifty-commit mailing list