rubengc/cmb2-field-ajax-search

Massive issues when putting ajax-populated box in a Repeater field

Opened this issue · 10 comments

jmarx commented

Whenever creating a group with repeatable fields, I cannot get the the ajax fields to work properly.
I am able to select an option, but when I click on the text, I get an ugly error and the value does not get saved to the database. Has anyone else come across this?
jserror

Yes, unfortunately, this plugin is not compatible with field type group - it generates incorrect input[name] and data is not saved because of that.

@rubengc Is it possible that you still have the interest in this plugin?

Hi there

From a year I didn't use this library since I switched to Select2 instead

Anyway, if you send any PR with bug fixes I will approve it

Mte90 commented

Started working at #14

Mte90 commented

I did it, seems that there was a lot of issues and one of them is using multiple as parameter that is a reserved value for CMB2.
Anyway my pr fix also other problems and works with repeatable fields :-)

I did it, seems that there was a lot of issues and one of them is using multiple as parameter that is a reserved value for CMB2.
Anyway my pr fix also other problems and works with repeatable fields :-)

@Mte90 Thanks a lot for your work!

It is finished and should be working, correct? Since the pull request is still open after all this time, I tried merging it into the code myself, but for some reason I'm still having some issues. I'm using a single term search field inside a repeater. No errors in the console upon field entry or updating post.

When updating post, the fields get saved and I can retrieve data with get_post_meta just fine, but upon reload, the fields are displayed as empty. When updating the post again, the data is resaved as empty as well. This is a pretty big problem, as you would manually need to re-enter all the repeater content every time you need to update something in the post, or otherwise the data would be lost.

Any idea? I'm guessing the fields are simply not filled in the admin via AJAX or something like they should.

PS: Perhaps the problem is with how I'm merging your code, though. This issue appears when I manually copy the files from your last commit ('fixed frontend') and overwrite the base plugin with them. However, when I actually clone the repo from here https://github.com/Mte90/cmb2-field-ajax-search/tree/repeatable I'm back to the initial issue with the console error and no saving. After switching to 'repeatable' branch and pulling from there (though it was already up to date), I started experiencing this - after selecting a term from the ajax dropdown, it was immediately transformed into the term ID, and not saved on publish. I'm so confused... Perhaps you could send me a zip with the working plugin, if it's indeed fixed?

Mte90 commented

This Mte90@674f27a is not the last commit, this is the latest one Mte90@716920f

You can see at https://github.com/rubengc/cmb2-field-ajax-search/pull/14/files the code changes of my branch.
The error as I can remember is that this field doesn't use the HTML name propriety in the HTML standard way and with repeatable fields stop working at all.

My pr fix that issue, if @rubengc can merge it will be the best.

I tried the files from Mte90/cmb2-field-ajax-search@716920f, but with those I have the last issue I described (the ID transform one). When I click on the term, it gets instantly renamed into the term ID inside the field (e.g 6) and doesn't get saved to db.

Mte90 commented

I don't know I am not using the plugin right now and I don't have any issue reported.
You should investigate more about what is happening.

Aye, trying to. Unfortunately I'm a little out of my depth here as I'm not a backend dev.