Re: Problem with Rose::HTML::Form::Field::DateTime::Split::MDYHMS in 0.603

3 views
Skip to first unread message

Will Hawes

unread,
Aug 13, 2009, 8:59:07 AM8/13/09
to rose-htm...@googlegroups.com
The synopsis for Rose::HTML::Form::Field::DateTime::Split::MDYHMS
(http://search.cpan.org/~jsiracusa/Rose-HTML-Objects-0.603/lib/Rose/HTML/Form/Field/DateTime/Split/MDYHMS.pm)
runs OK, but if I try to add $field to a form and print the html:

my $form = Rose::HTML::Form->new;
$form->add_fields( $field );
print $form->html;

I get the following error:

Can't locate object method "items" via package
"Rose::HTML::Form::Field::DateTime::Split::MDYHMS" - no such method,
and none auto-created because it is not a valid HTML attribute for
this class at lib/Rose/HTML/Object.pm line 1008
       Rose::HTML::Object::AUTOLOAD('Rose::HTML::Form::Field::DateTime::Split::MDYHMS=HASH(0x224d4b4)')
called at lib/Rose/HTML/Form/Field/Collection.pm line 484
       Rose::HTML::Form::Field::Collection::fields_as_children('Rose::HTML::Form=HASH(0x22d9d1c)')
called at lib/Rose/HTML/Object/WithWrapAroundChildren.pm line 34
       Rose::HTML::Object::WithWrapAroundChildren::children('Rose::HTML::Form=HASH(0x22d9d1c)')
called at lib/Rose/HTML/Object.pm line 292
       Rose::HTML::Object::has_children('Rose::HTML::Form=HASH(0x22d9d1c)')
called at lib/Rose/HTML/Form/Field/Collection.pm line 136
       Rose::HTML::Form::Field::Collection::html('Rose::HTML::Form=HASH(0x22d9d1c)')
called at script\synopsis.pl line 36

I see the same thing with
Rose::HTML::Form::Field::DateTime::Split::MonthDayYear.

I'm not sure if this is a bug or just me misunderstanding something,
but the following patch fixes it for me:

--- C:\Perl\site\lib\Rose\HTML\Form\Field\Collection.pm Fri Jul 24 16:25:52 2009
+++ lib\Rose\HTML\Form\Field\Collection.pm      Thu Aug 13 13:31:50 2009
@@ -481,7 +481,7 @@

  foreach my $field ($self->fields)
  {
-    if($field->is_flat_group)
+    if($field->is_flat_group && $field->can('items'))
    {
      push(@children, $field->items);
    }

patch.txt

John Siracusa

unread,
Aug 18, 2009, 10:26:41 AM8/18/09
to rose-htm...@googlegroups.com
On Thu, Aug 13, 2009 at 8:59 AM, Will Hawes<wdh...@gmail.com> wrote:
> The synopsis for Rose::HTML::Form::Field::DateTime::Split::MDYHMS
> (http://search.cpan.org/~jsiracusa/Rose-HTML-Objects-0.603/lib/Rose/HTML/Form/Field/DateTime/Split/MDYHMS.pm)
> runs OK, but if I try to add $field to a form and print the html:
>
> my $form = Rose::HTML::Form->new;
> $form->add_fields( $field );
> print $form->html;
>
> I get the following error:
>
> Can't locate object method "items" via package
> "Rose::HTML::Form::Field::DateTime::Split::MDYHMS" - no such method,
> and none auto-created because it is not a valid HTML attribute for
> this class at lib/Rose/HTML/Object.pm line 1008

I've fixed this in SVN 1983.

Also keep in mind that $form->html() almost certainly does not do what
you want it to do. There is no single HTML representation of a form.
RHTMLO expects you to lay out your form fields as desired (usually
using some sort of templating language that calls back into your
objects to get the HTML for each field, label, etc.)

The closest thing to "a generic HTML representation of a form" is the
(still undocumented, sorry) $form->html_table method.

-John

Reply all
Reply to author
Forward
0 new messages