Restore custom field checkbox and radio button values when switching model
This commit is contained in:
parent
ddd4065c81
commit
29433882ea
1 changed files with 11 additions and 0 deletions
|
@ -221,6 +221,17 @@
|
|||
//now re-populate the custom fields based on the previously saved values
|
||||
$('#custom_fields_content').find('input,select').each(function (index,elem) {
|
||||
if(transformed_oldvals[elem.name]) {
|
||||
if (elem.type === 'checkbox' || elem.type === 'radio'){
|
||||
let shouldBeChecked = oldvals.find(oldValElement => {
|
||||
return oldValElement.name === elem.name && oldValElement.value === $(elem).val();
|
||||
});
|
||||
|
||||
if (shouldBeChecked){
|
||||
$(elem).prop('checked', true);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
{{-- If there already *is* is a previously-input 'transformed_oldvals' handy,
|
||||
overwrite with that previously-input value *IF* this is an edit of an existing item *OR*
|
||||
if there is no new default custom field value coming from the model --}}
|
||||
|
|
Loading…
Add table
Reference in a new issue