reduxframework / redux-framework

Redux is a simple, truly extensible options framework for WordPress themes and plugins!

Home Page:http://redux.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Repeater extension : create unique ID for each entry

mzrahmani opened this issue · comments

Is it possible to create a unique ID for each entry in the repeater?
Using the array key is not unique if you delete an entry then create another one, you are using same array key for different entry.

I tried creating a text box - readonly - and using the "saved" action hook to set the value of that text box to use it as unique id, the issue is after saving the value that was set programmatically, the new value was not displayed in the option panel, disabling ajax did not fix that issue, it seems the values on the panel are not being reloaded after saving even if a page is reloaded.

Any way to force reload fields values ?

When dealing with arrays, there really isn't any other way to create unique IDs without array numbers. jQuery handles the way the repeater field organizes added and deleted items.

I must not be understanding the issue (forgetting that all the required information we asked for was not included, which was not optional). Setting individual fields inside repeater section programmatically based on the static index? I don't know if that's possible or easily done. Those numbers will always change with deletions. It can't be helped.

I created five repeaters, assigned index-specific data in the textbox, deleted the first, added another, deleted the third, added another, saved, and reloaded the page. All repeaters were properly reordered with the data intact. That's exactly how it's supposed to work. Based on how the repeater field retrieves the data for use in the project, the index number shouldn't matter.

Also, the 'saved' action hook fires AFTER saving. Try the 'before_validation' hook to manipulate data before saving. That's how we do it with other extensions.

Goog luck.