Hi again,

I have a very useful macro that was supplied from this list.
It allows persistence for all my select lists which is great, but
the first option (implicitly select all values) has no label.
I would like to use the label "All".  The code that unshifts
an empty element makes no sense to me, I can't see how
it even knows we are creating a select list.

Thanks for any insight.

Regards,

Kim


[% MACRO persistent_select_list(field) BLOCK;
    SET element = classmetadata.cgi.$field;
    # get the last value the field was set to, by  retrieving matching 
CGI parameter
    SET value   = request.query.$field;
    # put empty option at top if we don't have one
    IF (element.content_list.0.content_list) ;
        # -->>  would like to make the first item have a label called 
"All" but a value of empty string
        USE element_maker = Class("HTML::Element");
        SET element = element.unshift_content(
        element_maker.new("option", 'value', ""));
    END;

    FOR opt IN element.content_list;
        IF opt.attr('value') != value;
            opt.attr('selected', undef);
        ELSIF opt.attr('value') == value;
            SET myval = opt.attr('selected', 'selected');
            LAST;
        END;
    END;
    element.as_XML;
END;
%]


_______________________________________________
Maypole-users mailing list
Maypole-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/maypole-users

Reply via email to