<div class="form">
	<?php
  echo "<p data-translation-id ='ROUTING_INBOUND_NO_GATEWAY_NOTE' >".__('ROUTING_INBOUND_NO_GATEWAY_NOTE')."</p>";
  $form=$this->beginWidget('bootstrap.widgets.TbActiveForm', array(
		  'id'=>'routing-inbound-form',
		  'type'=>'horizontal',
		  'enableAjaxValidation'=>true,
		  'enableClientValidation'=>true,
		  'clientOptions'=>array(
				  'validateOnSubmit'=>true,
				  //'validateOnChange'=>false,
				  //'validateOnSubmit' => true,
				  //'afterValidate' => 'js:alert(1)'
				  'afterValidate' => 'js:aftValidate'
				  //'beforeValidate'=>"js:function(form) {
				  //    alert('this is bevore');
				  //}",
				  //'afterValidate'=>"js:function(form) {
				  //    alert('this is after');
				  //}",
		  ),
		  'htmlOptions'=> array('onsubmit'=>'return (document.getElementById("gw_id").options.length > 0) ? true : alert("Please create first Gateway")'),
		  'action'=>array('default/select'),
  ));
  
  echo CHtml::submitButton('create', array('id'=>'createGatewaysAction', 'style'=>'display:none'));
  
  $this->widget('bootstrap.widgets.TbButton', array(
		  'buttonType'=>'button',
		  'type'=>'primary',
		  'label'=>__('INBOUND_CREATE_GATEWAY'),
		  'loadingText'=>'loading...',
		  'htmlOptions'=>array(
				  'id'=>'createGatewaysButton',
				  'data-translation-id'=>'INBOUND_CREATE_GATEWAY',
		  ),
  
  ));
  
  $this->endWidget();

	?>
</div>
<!-- form -->
<script>
$('#createGatewaysButton').click(function() {
	var btn = $(this);
	btn.button('loading'); // call the loading function
	$("#createGatewaysAction").click();
});
</script>