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

[Question] Setting a position at 1 #149

Open
Guikingone opened this issue Jul 21, 2019 · 3 comments
Open

[Question] Setting a position at 1 #149

Guikingone opened this issue Jul 21, 2019 · 3 comments

Comments

@Guikingone
Copy link

Guikingone commented Jul 21, 2019

Hi everyone 👋

Small question about using a position field, is there any solution to use a position field starting at 1 rather than 0?

I know it can seems strange but I need to use a position which start at 1 and I can’t find a suitable solution to update the position field without overriding the after_* and before_* events 🤔

Thanks for the feedback 🙂

@stevro
Copy link

stevro commented Sep 17, 2019

@Guikingone , have you found a solution. I checked the source code and the function that actually writes the positions (doRewritePositions()) is called after the callbacks. So overwriting after_add doesn't seem to help.

What could help is an extra option named "first_position: 1" and use it in doRewritePositions

@stevro
Copy link

stevro commented Sep 17, 2019

I made a fork and added and extra option named position_field_first_value. If you still need it feel free to change the vcs source in composer.json to https://github.com/stevro/symfony-collection

@Guikingone
Copy link
Author

Hi @stevro 👋

I've found a solution by overriding the after_* event and lopping through every items which is handled for the position attribute and setting the value to the actuel key of the array (parseInt(value + 1)), that's clearly not the best solution but it seems to work 🙂

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

No branches or pull requests

2 participants