aldryn-forms icon indicating copy to clipboard operation
aldryn-forms copied to clipboard

select fields with list import

Open darioalbanesi opened this issue 10 years ago • 4 comments

possibility to import a list or copy/paste a list instead of creating each option 1 by 1. Would help on fields like the "Country" selection.

darioalbanesi avatar Nov 03 '15 15:11 darioalbanesi

This is a really cool idea :)

I think .csv would be best.

czpython avatar Nov 16 '15 10:11 czpython

Agreed, I missed that feature few times. Specifically for a country field I also have a snippet, I think it would make sense to try to add it to the package.

class CountryFormField(Field):
    name = _("Country Field")
    allow_children = False
    form_field = CountryField().formfield
    form_field_widget = CountrySelectWidget

    form_field_enabled_options = []
    fieldset_general_fields = []
    fieldset_advanced_fields = []

    def get_form_field_widget_kwargs(self, instance):
        return {
            'layout': '{widget}',
        }

    def get_form_field_kwargs(self, instance: Field) -> dict:
        kwargs = super().get_form_field_kwargs(instance)
        kwargs['label'] = ''
        return kwargs


plugin_pool.register_plugin(CountryFormField)

viktor-yunenko avatar Apr 05 '20 11:04 viktor-yunenko

Is this possible entirely within the scope of a field plugin (without changing code on the form class itself)? If yes, would it be recommendable to create such functionality in a separate repo / package?

macolo avatar Apr 05 '20 12:04 macolo

It's definitely possible, but after adding that snippet to ~5 projects over half a year it becomes apparent to me that it's more suitable for this repository :)

viktor-yunenko avatar Apr 05 '20 12:04 viktor-yunenko