-
Notifications
You must be signed in to change notification settings - Fork 920
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.0][Feature] Matrix field type (aka repeatable, aka multiply) #131
Comments
On the other hand, that "matrix" field option would NOT allow you to create matrixes of different field types. So it won't allow you to create, say, a repeatable "widget" for a person, that includes:
So maybe the matrix functionality should be implemented differently, something like: $this->crud->addField([ // matrix
'label' => "Team Members",
'name' => "team_members",
'type' => 'matrix',
'default_size' => 2,
'maximum_size' => 5,
'fields' => [
['name' => 'name', 'label' => "Name", 'type' => 'text'],
['name' => 'title', 'label' => "Title", 'type' => 'text'],
['name' => 'email', 'label' => "Email", 'type' => 'email'],
['name' => 'photo', 'label' => "Photo", 'type' => 'browse'],
['name' => 'bio', 'label' => "Bio", 'type' => 'textarea']
]
]); With the some advantages:
It does however pose a few questions:
...food for thought. |
So as it happens, I needed something similar to this when we were talking about the array field types and have already got a solution that works for my project, it however doubles up as the array field type. I'll push to a new branch so you can check it out soon |
Here is what I've been doing |
What you've shown there is awesome for an "array" field type. But they key difference in what I imagine the "matrix" field type to be is that it allows some fields to be of other types (number, wysiwyg, image, etc) - and the "array" field type you've pushed does not. I think it would be clear if we have these two fields:
Right? |
Sure :) I did actually like the idea of the field types, which we could implement into the array style one if we wanted, but the full matrix one could become complicated with the layout if you're thinking of things like image uploaders and wysiwyg. |
Agreed. Let's table it for now. We'll see if we can include it in v4. |
Hey @tabacitu @OwenMelbz ive been absent from laravel for a while, im at a new job and they use Craft
Im keen to get this done in the next couple of weeks so maybe discuss further on gitter to get the ball rolling? |
Fine by me :) Although just to clarify - I think what you're suggesting seems to be more of a "page builder" in my eyes to have a flexible content system? rather than a repeatable field that can have different content types in? |
@b8ne - sounds like something Backpack's missing. Go for it! My advice - try to build the most basic package, launch it and get feedback from the community ASAP. Otherwise you could end up spending a lot of time building something of little interest. Happened to me a number of times :-) |
It thinks this is a very flexible & useful feature that would be a great addition to Backpack. This sort of functionality is very common & popular in the WordPress world. Pretty much all the major custom field implementations support this. E.g. Advanced custom fields (1+ milloin active installations) has Repeater and Flexible content fields. |
@tabacitu Hey Christian! Saw that you're in Romania... met my wife in Romania in Constanta 10 years ago :-) Beautiful area. Is there a beta or semi-working version of the proposed Matrix field that I could get my hands on? Or, has anyone in this thread been successful in accomplishing this sort of function? @aripekkako? The Repeater/Flexible Content solutions would be perfect in Laravel Backpack. |
Hi @simplusgroup , I'm originally from Romania, yes, but don't hold it against me :-) I don't identify much as a Romanian - as BS as that sounds, so I'm away half the time. I agree, beautiful country, but poorly managed. There's isn't any working version that I know of, unfortunately. It is a very very important feature, though, so it is coming in 3.5 or 4.0. We will support this, in a beautiful way, but not at the moment. Until then, you could start from the Cheers! |
Hey @simplusgroup I spent a day on this a while ago. Got pretty far in terms of templating - its actually pretty simple to setup arrays of fields in the Controller then iterate over them in the view template. The main blocking issue I found was the way we currently handle JS and CSS. A lot of it is injected at compile time and set to run on DOM ready/load, so it cant be re-used when you "add" another field dynamically. |
I have a solution neither and agree with @b8ne that the full solution should be using the new asset management feature. I've diven into the WordPress Advanced Custom Fields implementation quite deeply in my former job and from that experience I can say that all fields that use JavaScript to initilize something (like a date picker) need to take the matrix implementation into consideration, if it is going to work. This is because the field duplication has to be done with JavaScript and when the duplication is done, all the related JavaScript plugins need to be initialized. Essentially this means that there needs to be some sort of an event that is triggered when the fields are rendered that the JS-initialization can then be connected to. Looking forward to @tabacitu beautiful implementation. ;) |
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: #2266 |
I just thought of something, which changes everything [kidding, it would only change the need for this field type, I just like to make fun of Apple :-) ]. A medium-term functionality I had in mind was what I used to call "matrix fields". Like the "array" field should do for the "text" fields, the "matrix" fields would allow you to make an array of any type of field, and let the admin add more and reorder them.
I now think the name is pretty lame and that it shouldn't be included as a type of field, but maybe it makes more sense, rather than have an
array
field for text fields, to have an option on ALL field types.So you'd just add some new optional attributes to your field's definition, something like:
And this would:
name[]
instead ofname
;Wouldn't this be an awesome awesome feature?
The text was updated successfully, but these errors were encountered: