the question says it all, yesterday I asked How to add fields to activeform with js/jQuery in Yii2?
well now I need to add a dropdown menu and is is not the same thing...
I have this:
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use app\models\User;
use app\models\ContactType;
$cntcttp = new ContactType;
$this->registerJs('$("#btnadd").on("click",function(){'
. '$("#dynamicInput").append(\''
. Html::textInput("contacto","",['placeholder'=>"contacto"])
. '\');'
. '})');
?>
<?php $form = ActiveForm::begin(); ?>
<div id="dynamicInput"></div>
<?= Html::activeDropDownList($cntcttp, 'ContactTypeID',
ArrayHelper::map($ctypes, 'ContactTypeID', 'Name') , ['prompt'=>'--contacto--']) ?>
<input type='button' id='btnadd' value="add contact">
<div class="form-group">
<?= Html::submitInput('Submit', ['class' => 'btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
now I need to make the dorpdown appear when the user clicks the #btnadd instead of what I have now :P
Thank you in advance :)