[html-formfu] How to remove enclosing div for a text input element

Carl Franks fireartist at gmail.com
Wed Apr 4 14:15:50 GMT 2012

...or add a new option to skip auto-adding classes :)
Probably the least work for this specific case, though maybe not if
there are many more changes required for bootstrap

On 4 April 2012 15:11, Brian Cassidy <brian.cassidy at gmail.com> wrote:
> On Wed, Apr 4, 2012 at 10:30 AM, abhishek jain
> <abhishek.netjain at gmail.com> wrote:
>> I don’t want the default values: i just want <div class="row ">
> Ah yes, it's all becoming clear now -- this is an inherent problem
> with how FormFu does its rendering.
> Before I try to reason this all out, I should tell you that I'm also
> playing around with Twitter's Bootstrap framework [1] in conjunction
> with FormFu forms -- more on that later.
> So, the way I've traditionally rendered forms was by simply using the
> render() method. I was always pleased with the output. But as you've
> noted, the current output does not match what Bootstrap wants.
> If you look closely at the Role::Element::Field source code, you'll
> see this (shortened slightly to save space):
> sub _render_container_class {
>    my ( $self, $render ) = @_;
>    my $type = $self->type;
>    $type =~ s/:://g;
>    append_xml_attribute( $render->{container_attributes}, 'class',
> lc($type), );
>    return;
> }
> This means that no matter what you put in your config for this form,
> it will *always* add a class for the type of element we're dealing
> with (text, for e.g.). the "del_container_attrs" method will have no
> effect due to the fact that it is called when the config file is read,
> which happens before you render anything.
> IMO, this means that string rendering is out.
> Side bar: Also, IMHO, rendering should be done via a completely
> different set of modules -- which means you could do:
> my $r = HTML::FormFu::Renderer::Basic->new;
> print $r->render( $form );
> Or write a bootstrap specific renderer for our purposes. (Note:
> render() could be a simple wrapper around the above for compatibility)
> Anyway, back on track. Next we try the TT rendering method.
> Unfortunately, the same data is injected into the attribute list.
> Thus, we have to make our own set of templates! ...and that's where
> I'm at. I have a set of custom templates that *seem* to work okay with
> the bootstrap framework, in my limited testing.
> I would be happy to share them with you off-list if you would like.
> Eventually it would be nice to put them up on github or the like for
> everyone to use.
> I think the takeaway here is that if you want radically customized
> templates you either have to create your own rendering method which
> circumvents the built-ins, or use a custom set of templates.
> Hope that helps!
> [1] for those of you not aware of Bootstrap:
> http://twitter.github.com/bootstrap/
> --
> Brian Cassidy (brian.cassidy at gmail.com)
> _______________________________________________
> HTML-FormFu mailing list
> HTML-FormFu at lists.scsys.co.uk
> http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu

More information about the HTML-FormFu mailing list