Crud: [4.0][Feature request][Important] Matrix field type / ability to select multiple field in table

Created on 5 Jul 2017  ยท  27Comments  ยท  Source: Laravel-Backpack/CRUD

Can I change table field column from text to another field like upload or select2?

Feature MUST question

Most helpful comment

Hi @rasez ,

There's currently no way to do that automatically - you should create another field type starting from table that uses the field type you need. But such a feature IS planned. Work-in-progress name is "the matrix field" and it should allow us to create a table with any combination of field types. But it's a lot more complicated than it sounds and it will require a rewrite of all fields, in order to reuse them. So it's unlikely this will happen in this current version. But the next version will definitely have it.

Cheers!

All 27 comments

Try this

Delete the field that you want to change with:

$this->crud->removeField('name', 'update/create/both');
And then add the field:

$this->crud->addField([ 
   'label' => "Category",
   'type' => 'select2',
   'name' => 'category_id', // the db column for the foreign key
   'entity' => 'category', // the method that defines the relationship in your Model
   'attribute' => 'name', // foreign key attribute that is shown to user
   'model' => "App\Models\Tag" // foreign key model
]);

I think that this is not what @rasez meant with his question. If I understood well the question, you are asking for changing the input types in the table field type, right? https://laravel-backpack.readme.io/docs/crud-fields#section-table

I think that this is currently not possible, but in my opinion could be a good new feature.

Yes, I meant that @ablunier

@ablunier @rasez - actually, can someone restate the question? I'd have thought https://github.com/Laravel-Backpack/CRUD/issues/771#issuecomment-313092348 might have been the answer but if it's not, I don't know what the question is actually asking.

(I know that @ablunier has restated it but it's not clear to me, still, what is being asked).

There is a table field in crud

[ // Table
    'name' => 'options',
    'label' => 'Options',
    'type' => 'table',
    'entity_singular' => 'option', // used on the "Add X" button
    'columns' => [
        'name' => 'Name',
        'desc' => 'Description',
        'price' => 'Price'
    ],
    'max' => 5, // maximum rows allowed in the table
    'min' => 0 // minimum rows allowed in the table
],

but all columns are text type it would be great if we can chose type of columns like upload,select2 or etc

[ed: added back ticks for the code :imp:]

Hi @rasez ,

There's currently no way to do that automatically - you should create another field type starting from table that uses the field type you need. But such a feature IS planned. Work-in-progress name is "the matrix field" and it should allow us to create a table with any combination of field types. But it's a lot more complicated than it sounds and it will require a rewrite of all fields, in order to reuse them. So it's unlikely this will happen in this current version. But the next version will definitely have it.

Cheers!

I want to know about the status of this feature is it possible to say when this feature is ready to use?

Hi @rasez . No updates. Definitely won't be ready in the next few months. It has HUGE implications. As I mentioned, I doubt Backpack 3.x will have it. I hope Backpack 4.0 will, but there's no work started for 4.x, nor a release date.

Till then you can do something like i did. I created a table-adv.blade.php field file where i did something like this so far

@foreach( $field['columns'] as $prop)
                            @if($prop['type'] == 'checkbox')
                                <td>
                                    <input type="checkbox" class="checkbox" ng-model="item.{{ $prop['name'] }}" />
                                </td>
                            @else
                                <td>
                                    <textarea class="form-control input-sm" @include('crud::inc.field_attributes') ng-model="item.{{ $prop['name'] }}"></textarea>
                                </td>
                            @endif
                        @endforeach

and in the field definition i added type after name and desc in the columns array... as you can see i only added checkboxes so far but you can go further.

How is this going? Where can we track this?

@doncadavona no updates on this yet, sorry. I'll make a note to reply here too when we have something.

/remind me in 2 months

@tabacitu set a reminder for Jun 24th 2018

:wave: @tabacitu,

Just want to chime in and voice that this is still a desired feature :) @tabacitu

Still nothing ? :) I think this table-matrix must have one more thing. Repeat all table.

Example:
In one "tab" i want enter 1,2,3..10 Clients and in all these clients must have enter multi inputs(table-matrix). And of course need column counting - optionality.

2 level depth repeat table-matrix :) Now i create this with custom-field, but with many jQuery and chaotic code.... :)

Done! The multiply field type allows you to group any number of Backpack fields into a container. Then that container can be multiplied any number of times. Currently looks a little underwhelming, but that can be easily improved:
Screenshot 2019-09-06 at 09 45 59

It's in PR https://github.com/Laravel-Backpack/CRUD/pull/1987 which will get merged soon, so I'm going to close the issue.

The field type is currently called multiply - it was a development name. Anybody has any idea of a better name? Ideas:

  • multiply
  • matrix
  • reapeatable
  • containers
  • boxes

None of them feel "right" to me...

for me best name are "reapeatable". Thanks for this solution!!! ๐Ÿ˜‰๐Ÿ‘๐Ÿค›๐Ÿ™Œ

flexible content field or flexible field is a term used in ACF/Wordpress for
this type of functionality.
Really excited that this is coming! Thanks for your work on it.
James

On Fri, Sep 6, 2019 9:17 AM, RaimisErvit [email protected] wrote:
for me best name are "reapeatable"

โ€”
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

Thanks @tabacitu , we hope it gets documented too, for us to read in the docs! :D
.
.
In addition to the said names, I'm thinking of the following:

  • grouped_fields

Great news @tabacitu !
And great job on V4 !

Omg I had so many problems with my own implementation, so happy to hear!

And I like "repeatable" one.

Repeatable is indeed nice. ACF also has "Repeater" field.

Done! The multiply field type allows you to group any number of Backpack fields into a container. Then that container can be multiplied any number of times. Currently looks a little underwhelming, but that can be easily improved:
Screenshot 2019-09-06 at 09 45 59

It's in PR #1987 which will get merged soon, so I'm going to close the issue.

The field type is currently called multiply - it was a development name. Anybody has any idea of a better name? Ideas:

  • multiply
  • matrix
  • reapeatable
  • containers
  • boxes

None of them feel "right" to me...

cool but it can add and remove with foreign keys? when it will be available to use

@samuk190 it'll probably be launched in 1-2 weeks

@tabacitu any news on the release date? Thanks

iu

We finally have a PR for this! We've been using it in client projects for a while now, it has no known bugs and it _should_ be pretty stable. But it needs extensive testing, before we can release it for thousands of projects to use.

Let's move the conversation in the PR please: https://github.com/Laravel-Backpack/CRUD/pull/2266

Done! The multiply field type allows you to group any number of Backpack fields into a container. Then that container can be multiplied any number of times. Currently looks a little underwhelming, but that can be easily improved:
Screenshot 2019-09-06 at 09 45 59

It's in PR #1987 which will get merged soon, so I'm going to close the issue.

The field type is currently called multiply - it was a development name. Anybody has any idea of a better name? Ideas:

  • multiply
  • matrix
  • reapeatable
  • containers
  • boxes

None of them feel "right" to me...

Thanks a lot for your awesome work @tabacitu

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jorgepires picture jorgepires  ยท  3Comments

mklahorst picture mklahorst  ยท  3Comments

AlexanderWM picture AlexanderWM  ยท  3Comments

M0H3N picture M0H3N  ยท  3Comments

voidstate picture voidstate  ยท  3Comments