Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No input with nested MultipleInput after remove #252

Open
bscheshirwork opened this issue Nov 14, 2018 · 3 comments
Open

No input with nested MultipleInput after remove #252

bscheshirwork opened this issue Nov 14, 2018 · 3 comments

Comments

@bscheshirwork
Copy link
Contributor

bscheshirwork commented Nov 14, 2018

For nested MultipleInput I not have a any data in $_POST for this field in case delete all rows. For 1st level I can see empty string (also is not good, but it exist).

I expect same behavior for 1st and 2st level of MultipleInput

@unclead
Copy link
Owner

unclead commented Nov 17, 2018

Post an example of the code, please.

@bscheshirwork
Copy link
Contributor Author

    <?= $form->field($model, 'nestedObjects')->widget(MultipleInput::class, [
        'rendererClass' => \unclead\multipleinput\renderers\ListRenderer::class,
        'max' => 6,
        'min' => 1,
        'allowEmptyList' => false,
        'enableGuessTitle' => true,
        'addButtonPosition' => MultipleInput::POS_HEADER, // show add button in the header
        'enableError' => true,
        'columns' => [
            [
                'name' => 'nested1', // attribute
                'title' => Yii::t('object', 'Nested1'),
                'type' => MultipleInput::class,
                'options' => [
                    'max' => 12,
                    'min' => 0,
                    'allowEmptyList' => true,
                    'enableGuessTitle' => true,
                    'addButtonPosition' => MultipleInput::POS_HEADER, // show add button in the header
                    'enableError' => true,
                    'columns' => [
                        [
                            'name' => 'nested2', // attribute
                            'title' => Yii::t('object', 'nested2'),
                        ],
                    ],
                ],
            ],
        ],
    ])
        ->label(false);
    ?>

@bax234
Copy link

bax234 commented Apr 30, 2024

    <?= $form->field($model, 'nestedObjects')->widget(MultipleInput::class, [
        'rendererClass' => \unclead\multipleinput\renderers\ListRenderer::class,
        'max' => 6,
        'min' => 1,
        'allowEmptyList' => false,
        'enableGuessTitle' => true,
        'addButtonPosition' => MultipleInput::POS_HEADER, // show add button in the header
        'enableError' => true,
        'columns' => [
            [
                'name' => 'nested1', // attribute
                'title' => Yii::t('object', 'Nested1'),
                'type' => MultipleInput::class,
                'options' => [
                    'max' => 12,
                    'min' => 0,
                    'allowEmptyList' => true,
                    'enableGuessTitle' => true,
                    'addButtonPosition' => MultipleInput::POS_HEADER, // show add button in the header
                    'enableError' => true,
                    'columns' => [
                        [
                            'name' => 'nested2', // attribute
                            'title' => Yii::t('object', 'nested2'),
                        ],
                    ],
                ],
            ],
        ],
    ])
        ->label(false);
    ?>

I was trying this example and combine with Tabular widget. In my case it's works, but need little bit event afterInit and afterAddRow to make custom generate element multidimesional array on second level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants