Skip to content

Proposal: component to handle form collections #3

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

Open
jmsche opened this issue Dec 3, 2020 · 19 comments · May be fixed by #398
Open

Proposal: component to handle form collections #3

jmsche opened this issue Dec 3, 2020 · 19 comments · May be fixed by #398

Comments

@jmsche
Copy link
Contributor

jmsche commented Dec 3, 2020

It would be nice if there was some available JS in the ux components to add basic stuff to handle form collections (add & remove) :)

@kriskoch
Copy link

kriskoch commented Dec 3, 2020

100%. Literally the first thing I thought of when I ready the post was "I wonder if they did this whole initiative just to make UX easier with form collections"

@benr77
Copy link

benr77 commented Jan 30, 2021

Same for me - form collections were my first thought when hearing about the UX

Has there been any movement on this issue anywhere?

@tgalopin
Copy link
Contributor

Not yet but we are open to contribs :) !

@stakovicz
Copy link

Hi everyone,

I just made my first Symfony bundle which should meet your need.
I would like to develop it further and why not propose it to the community.
What do you think ?
https://github.com/stakovicz/ux-collection

Here you have the demo code:
https://github.com/stakovicz/ux-collection-test

@benr77
Copy link

benr77 commented Apr 28, 2021

@stakovicz Awesome work - I took a quick look at the bundle and it looks good! I will try and test it out in a project of mine later this week.

@daFish
Copy link
Contributor

daFish commented Apr 28, 2021

@stakovicz I just tested your bundle in an application of mine. At first glance it worked pretty good. Just install, change the form type and you're good to go.

It would be great if we could be able to customize the way entries are added, e.g. if you want to use tables. Otherwise good work. 👍

@stakovicz
Copy link

@stakovicz I just tested your bundle in an application of mine. At first glance it worked pretty good. Just install, change the form type and you're good to go.

It would be great if we could be able to customize the way entries are added, e.g. if you want to use tables. Otherwise good work. 👍

Thanks, I'll see what I can do.

@benr77
Copy link

benr77 commented Apr 28, 2021

Just install, change the form type and you're good to go

This is great! Low entry barrier to using the bundle :)

@stakovicz
Copy link

Hi @tgalopin,

What do you think of my bundle?
https://github.com/stakovicz/ux-collection

What would be missing to integrate it into Symfony UX?

@tgalopin
Copy link
Contributor

tgalopin commented Apr 30, 2021

Hey @stakovicz !

I didn't have much time to review it in details, but I see that you are already using Symfony UX :) ! The plug and play behavior isn't linked to the Symfony namespace, your bundle already is integrated with Symfony UX.

Regarding putting it under the Symfony namespace, it does seem to be a great fit and a well implemented bundle, I'd be happy to review a PR to add the component.

I'd probably name it UX Form Collection (UX Collection is maybe a it too generic).

@jmsche
Copy link
Contributor Author

jmsche commented Apr 30, 2021

Hi @stakovicz,

One thing I think your package is missing is handling an other prototype name than __name__, which can be useful for nested form collections.

@stakovicz
Copy link

Hey @stakovicz !

I didn't have much time to review it in details, but I see that you are already using Symfony UX :) ! The plug and play behavior isn't linked to the Symfony namespace, your bundle already is integrated with Symfony UX.

Regarding putting it under the Symfony namespace, it does seem to be a great fit and a well implemented bundle, I'd be happy to review a PR to add the component.

I'd probably name it UX Form Collection (UX Collection is maybe a it too generic).

Hi @tgalopin,

Thanks for your support !

I do the changes for the namespace and the name here :
stakovicz/ux-collection@e3922b3

But I don't know how I can make PR on a bundle that doesn't exist.

@richardhj
Copy link
Contributor

richardhj commented May 3, 2021

But I don't know how I can make PR on a bundle that doesn't exist.

Create a new folder inside src/ within this repository and copy your bundle inside this folder :-)
(The namespace must match, see the composer.json of other bundles inside this monorepo)
The src/ folder will be split into individual repos.

@stakovicz
Copy link

Thanks @richardhj !

I did my first PR 🥳

@stakovicz
Copy link

One thing I think your package is missing is handling an other prototype name than __name__, which can be useful for nested form collections.

@jmsche you would like to have an attribute to use a custom placeholder __name__ ?

@jmsche
Copy link
Contributor Author

jmsche commented May 3, 2021

One thing I think your package is missing is handling an other prototype name than __name__, which can be useful for nested form collections.

@jmsche you would like to have an attribute to use a custom placeholder __name__ ?

I'm not sure I understand the question.

You should be able to pass the prototype name from the Form Type to the view, then it will be available in the form vars, so you can pass it from the view to JS using a data attribute.

I hope it answers your question :)

@stakovicz
Copy link

@jmsche I'm not sure about that you want :)

Has you can see here :
https://github.com/stakovicz/ux/blob/main/src/FormCollection/Resources/assets/src/controller.js#L62-L68
the __name__ is replace by the index.
So you want to manipulate it ?

@jmsche
Copy link
Contributor Author

jmsche commented May 4, 2021

The idea is to pass the prototype name from the Form Type to the view and finally to JS like this:

  • In Form Type: add prototype name to view vars in buildView()
  • In template: add a data-{{ controllerName }}-prototype-name attribute with the value coming from view vars
  • In JS: use this data attribute value instead of __name__

@stakovicz
Copy link

@jmsche I've removed the hard coded property_name value.
I use a Stimulus value passed from the view to the JS.

@dunglas dunglas linked a pull request Jul 18, 2022 that will close this issue
2 tasks
weaverryan added a commit that referenced this issue Nov 1, 2022
# This is the 1st commit message:

WIP heavy refactoring to Component

Initial "hook" system used to reset model field after re-render

Adding a 2nd hook to handle window unloaded

reinit polling after re-render

Adding Component proxy

# This is the commit message #2:

fixing some tests

# This is the commit message #3:

Refactoring loading to a hook

# This is the commit message #4:

fixing tests

# This is the commit message #5:

rearranging

# This is the commit message #6:

Refactoring polling to a separate class
daFish pushed a commit to daFish/ux that referenced this issue Jan 26, 2023
# This is the 1st commit message:

WIP heavy refactoring to Component

Initial "hook" system used to reset model field after re-render

Adding a 2nd hook to handle window unloaded

reinit polling after re-render

Adding Component proxy

# This is the commit message symfony#2:

fixing some tests

# This is the commit message symfony#3:

Refactoring loading to a hook

# This is the commit message symfony#4:

fixing tests

# This is the commit message symfony#5:

rearranging

# This is the commit message symfony#6:

Refactoring polling to a separate class
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

Successfully merging a pull request may close this issue.

7 participants