michaeluno / admin-page-framework

Facilitates WordPress plugin and theme development.
http://admin-page-framework.michaeluno.jp/
Other
339 stars 71 forks source link

Sorting and Repeating Groups of Fields #176

Closed baskettcase closed 9 years ago

baskettcase commented 9 years ago

Im trying to figure out how to have two fields, name and description that go together and then when you click the repeatable button it duplicates both of them. I set the section to repeatable and that's working. Now when I have multiples of the name and description fields I would like to be able to sort these. Im stuck on that part and can't figure it out. It only wants to sort name or description, but not the block of name and description. Is there a way of doing this with the current system or is this a feature request?

michaeluno commented 9 years ago

Sortable sections are not supported yet.

You need to create a custom field type. Which field types do you need to group?

baskettcase commented 9 years ago

A text and textarea field. I'm really struggling with this framework for some reason. I'm sure I'm missing something simple. 

For example, I have two pages and the second page will not show the option fields, yet the first page will. If I remove the first submenu then the second one works. I add it back and it doesn't work anymore. I've tried making it two different classes outside of the core, but still, nothing on the second submenu page, although the submit button shows up. Is it even possible to do two different pages of options and each page saves it's own option variable?

michaeluno commented 9 years ago

There is not an instant way to sort groups of fields at the moment as sortable sections is not supported yet.

Are you comfortable with using a custom field type? (It will be a little bit complicated if you are not familiar with coding in PHP.)

Update: I've missed your updated information in your last reply . For a different issue, post a new topic about it.

baskettcase commented 9 years ago

Yeah Im comfortable in PHP, but OOP is still a bit new to me and inheritance, etc so Im struggling with that. I should be able to look at your example custom file and hopefully pull something out. Ill post to another thread for the other help.

michaeluno commented 9 years ago

I've posted an example plugin. https://gist.github.com/michaeluno/6c666aacb3d33ec9be48

It has two files. One is the main plugin file and the other one is a file defining a custom field type. Place them in the same directory. The main plugin file will try to find the other file in the same directory.

baskettcase commented 9 years ago

Awesome thanks! Ill give it a try.

baskettcase commented 9 years ago

It worked amazingly well, thank you very much!

michaeluno commented 9 years ago

Glad it helped!