wbraganca/yii2-dynamicform

BC BREAK: Regexp change breaks nested dynamicforms

tafid opened this issue · 8 comments

tafid commented

The recent Pull Request #256 contains a regression. When dynamic forms are nested (as shown in the Demo 3, the updated regular expression leads to wrong parsing of inner dynamicform instance that leads to break of sequence enumeration and, as a result, break of custom scripts that rely on the sequential input ID's.

From my point of view, that commit should be reverted and the problem with UUID should be re-evaluated with a proper testing.

Confirmed

Done! Thanks.

Thank you for a prompt reaction

tafid commented

Thanks!

#265

Many be it is good regex for solving? ^(.+?)((?:-[\d]{1,})+)(.+)$
https://regex101.com/r/F93CGX/1

In my opinion, this regex must be configurable like this.

DynamicFormWidget::begin([
                    'widgetContainer' => "dynamicform_wrapper"
                    'widgetBody' => ".container-items"
                    'widgetItem' => ".item"
                    'min' => 1, // 0 or 1 (default 1)
                    'insertButton' => ".add-item"
                    'deleteButton' => ".remove"
                    'model' => $personalData[0],
                    'formId' => 'common-form',
                    *'regexID' => "^(.+?-$model->tour_id-.+?)(-\d{1,}-)(.+?)$",*
                    *'regexName' => "(^.+?\[$model->tour_id\]+.+?)(\[\d{1,}\]{1,})(\[.+\]$)",*
                    'formFields' => [
                        'first_name',
                        'last_name',
                        'birth_date',
                        'gender',
                        'citizenship',
                        'passport_number',
                        'passport_expire_date',
                        'file'
                    ],
                ]); ?>

@wbraganca

I have several projects where I have extract this widget and make this regexID, regexName
configurable.

If you'd like I could make a merge request with this future. )