Repeatable fields sortability
-
I’m wondering if the drag-ability of repeatable fields has some hidden sort value? I cannot figure out where the sort is stored; I did a print_r of the simple_fields_fieldgroup() and couldn’t find it.
As a workaround I’ve had to put a sort field in, and manually update it. Surely there is a better way?
Here is my code currently:
// now get simple fields. They may not be in the right order, so we build an array using the sort value $mysimple_fields_values = simple_fields_fieldgroup('sections' ); //dprint_r($mysimple_fields_values); $simplevalues = array(); foreach ($mysimple_fields_values as $value) { $simplevalues[$value['sort']] = array( 'anchor'=>$value['anchor'], 'subsection_class'=>$value['subsection_class'], 'subsection_content' => apply_filters('the_content', $value['subsection']) ); } $count_of_fields = count($mysimple_fields_values); for ( $x = 0; $x <= ($count_of_fields); $x++) { echo $simplevalues[$x]['sort']; $my_anchor = $simplevalues[$x]['anchor']; if ($my_anchor == '') {continue;} $my_subsection_class = $simplevalues[$x]['subsection_class']; $my_subsection_content = $simplevalues[$x]['subsection_content']; echo "<a name='$my_anchor'></a>"; echo "<div id='$my_anchor' class='subsection $my_anchor $my_subsection_class'>"; echo $my_subsection_content; echo "</div><!-- /$my_anchor -->\n"; echo '<div class="clear"></div>'; echo "\n\n\n"; }
- The topic ‘Repeatable fields sortability’ is closed to new replies.