Flutter get group duplicate issue

Flutter is a very handy WordPress plug-in that overwrite basic custom fields and turn it to something that provide higher user experience. However, there are many issues that have not been fixed. Also flutter development team seem to stop developing this powerful plug-in since July, 2009.

Get duplicate group is one of the key issues. Flutter use javascript serialize function to allows user creates unlimited group of the input fields. Unfortunately, the default function to presents the group of values is not that accurate.

Default methodology to get duplicate groups

Flutter presents document on how to get the duplicate group here.

This function return the number of duplicate group by the given field name. Then, developer need to loop through this number and use get function to present their desire fields. Please find an example of the usage below.

The problem

Code above seem to be fine if user add group and click update at every time. However, if user decided to add group and remove it, then add another one before click on update/publish button – it will generate the interval between group index. For example, instead of grouping like myField[0] –  myField[1] –  myField[2] the group index may become myField[0] myField[3] myField[5].  The first case will be fine to use default method but the later one will have the problem as value of second index will be disappeared and the loop will never meet the index 5.

The solution

To avoid this issue, developer need to do manual query for the number of duplicate group, plus the index of each group number. Please consider the code below.

Function

This function query the index of each group by the given field name (not just the amount). Copy and paste the code above to functions.php in the theme folder. Then replace the default usage with the following code in your theme file.

Usage

That’s it. Please excuse my English, if you have any question about this, feel free to use the comment below.

  • http://info@argonius.com Goran

    Thank you so much:D I am trying to solve this problem for two hours. I was thinking that I made mistake somewhere, never had even idea that this is a bug.

    Tnx, and best wishes in future work:)

  • http://chanon-srithongsook.info Chanon

    I’m very please, Goran.

    Thank you for saying thanks …. :)

  • K_P

    Thank You very much !

    You made my day.

  • http://chanon-srithongsook.info Chanon

    My pleasure K_P :)
    I was in your situation for a while, so annoy lol.

  • ananadli .

    Hi, can u tell me where i should put the code and where is the theme file is located? thank you =)

  • ananadli .

    Hi, can u tell me where i should put the code and where is the theme file is located? thank you =)

  • ananadli .

    i couldn’t locate my theme file

  • I donate $100/mo, why?

  • My Photography

  • Above the crowd Cage Side forward Walk away Endless rain Vivid Sydney Before Dawn