-
Notifications
You must be signed in to change notification settings - Fork 572
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Radio button input isn't saved when adding page to repeatable group #150
Comments
One thing I just discovered is that when you Add another row/group, the radio button This is a radio button from a group that saved properly:
This is a radio button from the new group:
The differences is that the newly added fields don't have a |
I believe I've found the problem and figured out a solution for this. It would be great if you could release this fix so any of your new updates of the plugin don't overwrite the changes I've hacked into a production site. The problem is that after you clone a row, you empty all the values of the input items. This makes sense except for radio and checkbox fields. So in cmb2.js I modified the following: Line 351: $newInput
.removeClass( 'hasDatepicker' )
.attr( attrs );//.val('');
if ($newInput.attr('type')!='radio' && $newInput.attr('type')!='checkbox') {
$newInput.val('');
} Line 473 in the emptyValue function: $('input:not([type="button"],[type="radio"],[type="checkbox"]), textarea', row).val(''); |
Should be good in the trunk branch. please test. |
@jamiechong any chance to have tested this one yet? |
@tw2113 I can't say for sure. I'm no longer active on the project I was using this for. I think I switched to using the production CMB2, which means I was happy with the changes being merged in. It's been so long - can't honestly remember. |
No worries, thanks for responding. Going to close for the time being. If someone else comes back with similar issues, we can revisit. |
So I am still having a problem with radio buttons in group fields. I have a repeatable group field that assigns a layout with a radio button and all i want is for the radio buttons default to be checked so that the conditional statement would be true and the second wysiwyg field wont be showing. I am using cmb2 conditional for that part. So basically when you click the add new entry button in the group field the radio button is blank and the second wysiwyg field is showing but if click update page the radio buttons default gets check and the second wysiwyg field goes away. and then if you choose two columns it appears and again disappears if you select one column radio button so the conditionals are working but how do i get it to be set when add a new entry is clicked? here is my code for the group field
Any help would be great. Thanks |
Are the parts for CMB2 Conditional in this code snippet already? or is that being added/toggled elsewhere? Just wanting to make sure we have everything we need, other than CMB2 Conditional active, to recreate what you're experiencing. |
yeah they are the conditional-id and the conditional-value fields in the
cmb2 markup. and for the wysigwyg editor i found that you have to add a
after_field markup as well to get it to hide and show it.
|
@jtsternberg is the cmb.cleanRow() js method supposed to clear out checked/selected states when doing a clone appending? That's what I'm getting when I check the JS, but definitely not what @TheNewGuy16 is wanting. Not sure if there's going to be way to override this. |
I mean if there isn't a way to override its fine. Since when you are
filling out a section the user should check one or the other radio buttons
for columns which in turn would hide or display the wsiwyg editor. I was
just looking for a solution so that i could set a default in case the user
didnt check the radio button. but even if the default radio button stayed
checked i am not sure it would hide the wsiwyg editor untill the page was
save anyway....So maybe a better option would be to hook into the update
page button when the add new row button was clicked that would select the
default radio button and hide the wsiwyg editor.
|
Also curious if you could add your own snippet of js that checks after the ajax is done adding. Just throwing the thought out there, I lack an actual working solution for that one. |
With the metabox below I have a problem saving the radio button. To repeat the issue:
Note that if I have another field in there, say a text input, the 2nd page will save, but the radio button value doesn't get set.
Any thoughts on how I can fix this problem? I think it's the root to some other issues I'm having with adding rows/pages and then sorting...
The text was updated successfully, but these errors were encountered: