oetiker / callbackery

Callbackery a Frontend Builder Toolkit
GNU General Public License v3.0
11 stars 10 forks source link

Make URL form setting consistent with URL action calling #194

Closed zaucker closed 2 years ago

zaucker commented 2 years ago

Allow form entries from URL with

        {
            key    => 'nevis_test',
            label  => trm('Test'),
            widget => 'text',
            set    => {
                required => true,
                maxWidth => 300,
            },
            urlFormKey => 'test',
        },

in backend with URL http://localhost:7181/#app=HINPassword;test=test.

Note: Backward-incompatible change (of none-documented feature).

oetiker commented 2 years ago

I would suggest to call the url data functionality from within the loadData function, and thus merge any data coming from the server with the data given on the url before calling setData ... in this way any formReconf will get called as if the data came from the backend, and no strange things will happen from calling setData twice.

zaucker commented 2 years ago

I would suggest to call the url data functionality from within the loadData function, and thus merge any data coming from the server with the data given on the url before calling setData ... in this way any formReconf will get called as if the data came from the backend, and no strange things will happen from calling setData twice.

But then it will be called on every _loadData() and not just on appear. I guess this would probably work as the URL parameters are removed upon processing the first time. Is this what you want?

oetiker commented 2 years ago

no, the reason I am saying it is that loadData may cause formReconf and this may depend on the data entered in the form ... and if it gets filled with server data first, the reaction might be undesirable ...

hence I would merge the data

but yes guarding against repeated action is certainly a valid thing ...

the reason the 'original' code worked was because I never used it in connection with existing data

zaucker commented 2 years ago

I left the callback in the appear handler, but merge the backend and urlData before setting the form.

zaucker commented 2 years ago

ich wuerde nach moeglichkeit versuchen etwas weniger inline code zu machen ...

Suggestions comitted.