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

Splitting up forms over multiple cards #47

Open
JoepdeJong opened this issue Jan 22, 2023 · 2 comments
Open

Splitting up forms over multiple cards #47

JoepdeJong opened this issue Jan 22, 2023 · 2 comments

Comments

@JoepdeJong
Copy link

Hi everyone,

I have implemented blocks, which allow me to split op a crud form over multiple cards/columns using e.g. col-md-6.
Screenshot 2023-01-22 at 14 58 52

The config is similar to tabs: add 'block'=>'block_name' to a field. To customize blocks, e.g. styling and title, one can use blockOptions:

        $this->crud->setOperationSetting('blockOptions', [
            'general' => [
                'wrapper_class' => 'col-md-12 compact-form',
                'show_title' => false,
            ],
            'pickUpAddress' => [
                'wrapper_class' => 'col-md-6 compact-form',
                'title' => __('order.pick_up_address'),
                'show_title' => true,
            ],
            'deliveryAddress' => [
                'wrapper_class' => 'col-md-6 compact-form',
                'title' => __('order.delivery_address'),
                'show_title' => true,
            ],
            'goods' => [
                'wrapper_class' => 'col-md-12 compact-form',
                'title' => __('order.goods'),
                'show_title' => true,
            ],
            'goodsRetour' => [
                'wrapper_class' => 'col-md-12',
                'title' => __('order.goods_retour'),
            ]
            ]);

At the moment, I implemented this by overwriting the CrudPanel class and adding a Blocks trait. This means that it breaks when these files are updated in Backpack.

Do you know if there is any interest in this functionality? In that case, I could clean up my code, fork Backpack, and make a PR. Or are there any other possibilities to extend CrudPanel, Fields, and FieldsProtectedMethods without editing the backpack core?

@pxpm
Copy link

pxpm commented Jan 23, 2023

Hey @JoepdeJong thanks for providing such detail! 🙏

I always liked forms displayed like that and I think there is a simpler way for you to do that without overriding the CrudPanel class.

You can create a new create_with_blocks file, that is a copy of https://github.com/Laravel-Backpack/CRUD/blob/main/src/resources/views/crud/create.blade.php

In your CrudController CreateOperation setup, tell backpack to use this view: $this->crud->setCreateView('path.to.your.view')

You will probably need to create a custom form_content too https://github.com/Laravel-Backpack/CRUD/blob/main/src/resources/views/crud/form_content.blade.php

And I think you can achieve what you are looking for by creating those two files, without overriding nothing from the core.

Cheers

@pxpm
Copy link

pxpm commented Jan 26, 2023

Hey there @JoepdeJong
Probably using an Operation (basically a trait that you add to crud controller)?
That and the views would avoid overriding backpack crud panel class.
Cheers

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

No branches or pull requests

2 participants