CakePHP Repeat Input Elements

When developing an information system, the input need to be design properly especially  for the label, placeholder, validation and repeating input elements. Repeating input elements such as permanent address - postage address is very useful for end-user to replicate the input to another field. 

Assuming that the input name is address_permanent and address_postage, where the address will be the first input and if the postage address is same as permanent address, so the end-user only need to check the address box to replicate the input to another. The java script should be load before the first input as shown below in your view.

<!--JS for checkbox check value-->
<script>
function Address(f) {
	if(f.sameAddress.checked == true) {
			f.address_postage.value = f.address_permanent.value;
	}
}
</script>
				
<!--First input - Permanent Address-->
<div class="form-group">
	<?php echo $this->Form->input('address_permanent', array('class' => 'form-control', 'id' => 'address_permanent'));?>
</div>

<!--Checkbox-->
<input type="checkbox" id="sameAddress" onClick="Address(this.form)">
<em>Click if address is same</em>
	
<!--First input - Postage Address-->
<div class="form-group">
	<?php echo $this->Form->input('address_postage', array('class' => 'form-control', 'id' => 'address_postage'));?>
</div>

That all. Happy coding!