Dear Friends

Please, forgive me, i know, this is not a HTML::FormHandler related list, but i hope, there are a lot of people here who use it!

In a catalyst app, i'd like to disable (make the field readonly and disabled but not inactive) a form field based on a value (if user has the role, or not).
If i set "hardwired" in the form class:

has_field 'foo' => ( type => 'Text', element_attr => { readonly => 'readonly' }, disabled => 1 );

works perfectly.

But i'd like to apply the readonly/disabled attributes based on a boolean value in form class.

I see, there is a "html_attributes callback" but don't know, how to use it:
sub html_attributes {
    my ( $self, $obj, $type, $attrs, $result ) = @_;
    # obj is either form or field
    $attrs->{class} = 'label' if $type eq 'label';
    $attrs->{placeholder} = $self->_localize($attrs->{placeholder})
        if exists $attrs->{placeholder};
    return $attrs;
}

Thank You in advance!
Csabi


_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to