Dynamically Set wrapper_attr for subfields of Repeatable fields?

8 views
Skip to first unread message

Mark West

unread,
Mar 6, 2018, 6:20:47 PM3/6/18
to formhandler
Hello, 

I would like to be able to dynamically set a class attributes for subfields of a Repeatable field I have defined in a role: App::Form::Role:Repeatable::People

Is that possible? In various documentation I've seen references to using build_update_subfields for similar attributes in Compound fields. 

In the field below, I would like to set width attributes narrower and wider depending on which fields are displayed on a form.

narrow

has_field 'household_people.person.first_name' => (
    label => 'First Name',
    label_attr => {'class' => 'label-medium'},
    do_wrapper => '1',
    wrapper_attr => {
        class=> ['col-xs-3', 'col-md-3'],
    },
    type => 'Text',
    required => '1',
    element_attr => {
        class => ['input-sm'],
    },
);

wider
has_field 'household_people.person.first_name' => (
    label => 'First Name',
    label_attr => {'class' => 'label-medium'},
    do_wrapper => '1',
    wrapper_attr => {
        class=> ['col-xs-6', 'col-md-6'],
    },
    type => 'Text',
    required => '1',
    element_attr => {
        class => ['input-sm'],
    },
);

Thanks,

Mark


Reply all
Reply to author
Forward
0 new messages