To make the form behave as you described, you can modify the form fields and add some JavaScript to show or hide fields based on the selected value.
First, let's modify the form fields and add an onchange event to the "Half Day" checkbox:
html
<div class="form-group form-check col-sm-3 mt16 d-flex justify-content-center align-items-center">
<input class="form-check-input mr-2" type="checkbox" id="request_unit_half" name="request_unit_half" t-att-checked="leave.request_unit_half == True" t-attf-style="pointer-events: #{'none' if is_readonly else 'all'};" onchange="toggleFields()"/>
<label class="form-check-label ml8" for="request_unit_half">
Half Day
</label>
</div>
<!-- Hide the following field initially -->
<div class="form-group col-sm-3 mt8">
<label for="duration_display">Duration</label>
<input type="text" class="form-control" id="duration_display" aria-describedby="duration_display" placeholder="Duration" t-att-value="leave.duration_display" t-attf-style="pointer-events: #{'none' if is_readonly else 'all'};" readonly="readonly"/>
</div>
Next, let's create a JavaScript function to toggle the fields based on the "Half Day" checkbox value:
html
<script>
function toggleFields() {
if (document.getElementById('request_unit_half').checked) {