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

[4.1.x] Fluent syntax FieldGroup #2642

Closed
tabacitu opened this issue Apr 6, 2020 · 2 comments
Closed

[4.1.x] Fluent syntax FieldGroup #2642

tabacitu opened this issue Apr 6, 2020 · 2 comments

Comments

@tabacitu
Copy link
Member

tabacitu commented Apr 6, 2020

For when you want to apply a change/definition to multiple fields. The syntax I have in mind is something like this:

        CRUD::fieldGroup([
            CRUD::field('text'),
            CRUD::field('number')->type('number'),
            CRUD::field('email')->type('email'),
        ])
        ->tab('Simple')
        ->size(6);

The name might still need some work:

CRUD::fieldGroup([]); // singular
CRUD::fieldGroup([]); // plural maybe?!?!
CRUD::fields([]); // this already exists as a getter though

For this to happen, we need to create a new object, ex FieldGroup or FieldCollection, which would be Fluent to allow subsequent calls on it, and each call would basically forward that call to the fields inside that group, to modify their definition.

@sergeyugai
Copy link

sergeyugai commented Apr 13, 2020

hi @tabacitu,
here i am again with my backpack-fields package :)
I did something similar here: https://github.com/sergeyugai/backpack-fields-as-classes#field-collections - so once #2604 is resolved (or, well, when documentation is updated), I can re-generate my backpack fields and add your syntax as well.

Actually, there is one example missing from my readme:

$this->crud->addFields(


   FieldsCollection::make([
       NumericField::make('min_price_of_item', 'Min price of item'),
       NumericField::make('max_price_of_item', 'Max price of item')
   ])->prefix('$')->attributes(['step' => '5'])->tab('Pricing')->toArray()


);   

@tabacitu
Copy link
Member Author

tabacitu commented Jul 9, 2020

Update: there's a working PR for this from @pxpm . Anybody who stumbles upon this please check out #2951 . Especially you @sergeyugai - you have the most experience with this 😄

I'll close this issue since it's best to talk about it inside the PR.
Cheers!

@tabacitu tabacitu closed this as completed Jul 9, 2020
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

2 participants