Laravel-admin: Disable "New" or "Remove" with NestedForm

Created on 28 Jul 2017  路  8Comments  路  Source: z-song/laravel-admin

The nested form feature ($form->hasMany()) is really powerful.
How should we disable the "New" or "Remove" buttons? Some scenarios would require to not allow these ..or conditionnally

Most helpful comment

$form->hasMany('orders', function (Form\NestedForm $form) {

                        $form->text('id');
                        $form->text('description');
                    })
                        ->disableCreate()
                        ->disableDelete();

All 8 comments

i think i can use ->hasMany( ... )->setView('myview') to use another view and override... but I would strongly suggest that NestedForm has a method like disableNew and disableRemove or one for both.

@isometriq Would you care to explain how have you done this with a custom view?

@isometriq Don't worry, i got it, after thinking about your comment, thanks !!

@isometriq , Hi, well, you can't really use setView on this case because the $form->hasMany is an instance of FormNestedForm and NestedForm in this case doesn't have a setView method to replace its view.

So, you still can replace the view for get this done, but, it's gonna be used in your entire admin, you can't actually use a custom view just once, which is my case :C

Anyway, gonna wait for this.

Thanks !

@z-song Is it possible to disable new button in Hasmany form?

how disable new after add form ?

$form->hasMany('orders', function (Form\NestedForm $form) {

                        $form->text('id');
                        $form->text('description');
                    })
                        ->disableCreate()
                        ->disableDelete();

@fhferreira thanks a lot. The method you suggested is working.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chenyongmin picture chenyongmin  路  3Comments

cdhraesaemer picture cdhraesaemer  路  3Comments

evans-kim picture evans-kim  路  3Comments

qcol picture qcol  路  3Comments

MarKco picture MarKco  路  3Comments