wordpress-fieldmanager
wordpress-fieldmanager copied to clipboard
Allow non-identical child fields to be sortable
Currently, Fieldmanager is unable to sort unique fields within a group.
In the following example, the children of example_group
are not sortable:
$fm = new Fieldmanager_Group( array(
'name' => 'example_group',
'label' => __( 'Example group', 'namespace' ),
'sortable' => true,
'children' => array(
'unique_child_one' => new Fieldmanager_Group( array(
'label' => __( 'Child One', 'namespace' ),
'sortable' => true,
'children' => array(
// etc.
),
) ),
'unique_child_two' => new Fieldmanager_Group( array(
'label' => __( 'Child Two', 'namespace' ),
'sortable' => true,
'children' => array(
// etc.
),
) ),
'unique_child_three' => new Fieldmanager_Group( array(
'label' => __( 'Child Three', 'namespace' ),
'sortable' => true,
'children' => array(
// etc.
),
) ),
),
) );
A pair of workarounds are possible: one could create a separate sorting field, or potentially use identical repeating groups and use a select menu to set whatever unique value is required. But in some cases, I think it may be desirable to structure a field as I have in the above example.
It's also worth noting the UI for the above example sort of suggests that the fields are sortable: one can click and drag each unique FM group, but can't actually adjust the order of those groups.
What this is really asking for is a "sortable_children" => true
option. That would be tricky to build, but I can see the value in it.
+1 to this.
I am now hitting this same request: a fixed number of unique groups (known at run time) that I would like to be sortable, to set the front end order of what they contain. By way of an analogy, similar to (all else being equal) how the menu builder works in stock WP: drag and drop to set the menu order; I'm after the same idea here.
I'm very open to suggestions on how we can get this done.