<?php
$form = $this->beginWidget('ext.PlGrid.PlActiveForm', array(
    'id' => 'credential-Google',
    'gridId' => 'third-party-credentials-grid',
    'clientOptions' => array('validateOnSubmit' => false),
    'action' => $model->isNewRecord ? array('create') : array()
        ));
echo $form->dropDownListRow(
        $model, 'provider', $model->enabledProviders(), array(
    'data-translation-id' => 'THIRDPARTYCREDENTIAL_MODEL_PROVIDER',
    'onchange' => 'ajaxRenderForm()'));
echo $form->textFieldRow($model, 'title', array('data-translation-id' => 'THIRDPARTYCREDENTIAL_MODEL_TITLE'));
echo $form->dropDownListRow($model, 'addressBookId', $availableAddressBooks, array('data-translation-id' => 'THIRDPARTYCREDENTIAL_MODEL_ADDRESSBOOK_ID'));
echo "<div id='google-info'class='alert alert-info' data-translation-id='THIRDPARTYCREDENTIAL_GOOGLE_INFO'>" . __("THIRDPARTYCREDENTIAL_GOOGLE_INFO") . "</div>";
echo $form->errorSummary($model);

$this->endWidget();
?>
<script>
    $('#third-party-credentials-grid_Modal').removeClass('modal-large');
    
    function ajaxRenderForm() {
        $.ajax({
            url: "<?php echo url('phonesettingsThirdPartyCredentials/default/ajaxRenderModal'); ?>",
            type: "GET",
            dataType: "html",
            data: {provider: $('#ThirdPartyCredential_provider').val()},
            success: function (result) {
                $('#credential-Google').replaceWith(result);
            }
        });
    }
</script>