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.
getGroupDuplicates ($fieldName);
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.
$count = getGroupDuplicates("myField");
for($i = 0; $i < $count; $i++):
echo get("myField", $i);
endfor;
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
function getGroupOrderIndex($field_name, $pid = NULL){
global $post,$wpdb;
if (!$pid) $pid = $post->ID;
$fields = $wpdb->get_results("SELECT DISTINCT group_count FROM " . RC_CWP_TABLE_POST_META . " WHERE post_id = " . $pid . " AND field_name = '" . $field_name . "' ORDER BY order_id ASC");
foreach($fields as $field){
$indexes[] = $field->group_count;
}
return $indexes;
}
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
$groupIndexes = getGroupOrderIndex("myField");
foreach($groupIndexes as $index):
echo get("myField", $index);
endforeach;
That’s it. Please excuse my English, if you have any question about this, feel free to use the comment below.








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:)
I’m very please, Goran.
Thank you for saying thanks ….
Thank You very much !
You made my day.
My pleasure K_P
I was in your situation for a while, so annoy lol.