Merge pull request #16817 from marcusmoore/fixes/restore-custom-field-values-on-asset-edit-v2
Maintain checkbox and radio custom field values on asset edit page
This commit is contained in:
commit
6dbfc8875b
1 changed files with 11 additions and 0 deletions
|
@ -224,6 +224,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