CRUD
CRUD copied to clipboard
Add fluent field group
REFS: #2642
Address #2950
CRUD::fieldGroup(
CRUD::field('backpack')->label('backpacker'),
CRUD::field('backpacker')->label('backpack')
)->tab('Backpack Rocks')->label('Backpack Label Override Rocks.');
Just. Freaking. Awesome. Great work @pxpm ! This is the kind PR I love - surgical. Good job! Totally agree we need this - I will test and give feedback as soon as you let me know it's ready.
Cheers!
It's ok now @tabacitu you can test and merge.
Best, Pedro
@pxpm if using this code, removing $field->save();
public function __call($method, $parameter)
{
foreach ($this->fields as $field) {
$field->{$method}($parameter[0]);
}
return $this;
}
its working with nested group) Like this
CRUD::fieldGroup(
CRUD::fieldGroup(
CRUD::field('title'),
CRUD::field('descr')
)->size(6),
CRUD::fieldGroup(
CRUD::field('word'),
CRUD::field('char')
)->size(8)
)->tab('Test')
;
Indeed, calling the method directly allow us to remove the save call.
Thanks
@pxpm @tabacitu also, group works with colum) So...change method name to group?)
Nice, pretty sugar CRUD::group();
@pxpm @tabacitu also, group works with colum) So...change method name to group?) Nice, pretty sugar
CRUD::group();
I don't dislike it, if @tabacitu agree I am ok with the change to make it seamless to work with fields and columns. Or create a columnGroup() helper in case group() is too vague.
@pxpm @tabacitu also, group works with colum) So...change method name to group?) Nice, pretty sugar
CRUD::group();I don't dislike it, if @tabacitu agree I am ok with the change to make it seamless to work with fields and columns. Or create a columnGroup() helper in case
group()is too vague.
But it works with column atm
CRUD::fieldGroup(
CRUD::column('name'),
CRUD::column('order')
)->type('text');
Excellent idea with group @lotarbo - I think it's intuitive because it's similar to Route groups in Laravel. So it'd be:
CRUD::group(
CRUD::column('name'),
CRUD::column('order')
)->type('text');
CRUD::group(
CRUD::field('name'),
CRUD::field('order')
)->type('text');
I think that's a great idea!
What do you guys think of also supporting an array as parameter? (it's do the exact same thing)
It looks to me like it's easy to get confused what the parameter(s) for the group method should be, so it might be a good idea to support both.
CRUD::group(
CRUD::column('name'),
CRUD::column('order')
)->type('text');
// or
CRUD::group([
CRUD::column('name'),
CRUD::column('order'),
])->type('text');
Not sure about this one - asking for opinion.
Personally I'd probably go with arrays in my projects because I like the fact that I can end all lines with a trailing comma. Though I believe it also works in parameters for PHP 7.3+ I believe... So that would render that argument mute 😆
I think you are right about the 7.3 trailling commas. But if you think we should support arrays for < 7.3 i am ok with it, but i personally would not be using the array notation myself.
trailing comma works since php7.3, and i think, no need support array
Added support for array input and refactored name to CrudObjectGroup
@pxpm @tabacitu any news with this?)
Hello @lotarbo
This is pending review. We had some major bugs to work out first and freezed the introduction of features. I think it's stabilizing now and we should go back to features soon.
Did you tried this PR? It's working good? Give us some feedback it might help speed up the review process.
Best to you, Pedro
The inspection completed: 505 Issues, 79 Patches
hi, any progress in v6?