mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-30 20:55:42 +00:00 
			
		
		
		
	Logic fix for boolean fields in JS forms
This commit is contained in:
		| @@ -804,7 +804,9 @@ function updateFieldValue(name, value, field, options) { | |||||||
|  |  | ||||||
|     switch (field.type) { |     switch (field.type) { | ||||||
|     case 'boolean': |     case 'boolean': | ||||||
|         el.prop('checked', value); |         if (value == true || value.toString().toLowerCase() == 'true') { | ||||||
|  |             el.prop('checked'); | ||||||
|  |         } | ||||||
|         break; |         break; | ||||||
|     case 'related field': |     case 'related field': | ||||||
|         // Clear? |         // Clear? | ||||||
| @@ -2019,8 +2021,15 @@ function constructInputOptions(name, classes, type, parameters) { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (parameters.value != null) { |     if (parameters.value != null) { | ||||||
|  |         if (parameters.type == 'boolean') { | ||||||
|  |             // Special consideration of a boolean (checkbox) value | ||||||
|  |             if (parameters.value == true || parameters.value.toString().toLowerCase() == 'true') { | ||||||
|  |                 opts.push('checked'); | ||||||
|  |             } | ||||||
|  |         } else { | ||||||
|             // Existing value? |             // Existing value? | ||||||
|             opts.push(`value='${parameters.value}'`); |             opts.push(`value='${parameters.value}'`); | ||||||
|  |         } | ||||||
|     } else if (parameters.default != null) { |     } else if (parameters.default != null) { | ||||||
|         // Otherwise, a defualt value? |         // Otherwise, a defualt value? | ||||||
|         opts.push(`value='${parameters.default}'`); |         opts.push(`value='${parameters.default}'`); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user