1
문제가 모든 것을 말해이, 어제는 How to add fields to activeform with js/jQuery in Yii2?jQuery를 사용하여 activeDropDownList를 양식에 추가하는 방법은 무엇입니까? PHP - Yii2
가 아니라 지금은 드롭 다운 메뉴를 추가 할 필요가 물었다
나는이 가지고 ... 같은 것이 아니다된다 을 P가 사전에 감사합니다 :)
: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(); ?>
는 지금은 사용자가 대신 내가 지금 무슨의 #btnadd을 클릭하면 dorpdown 표시해야
내가 tryed, 그게 나에게 문법 오류를 알려주 : unterminated 문자열 리터럴 –
@ FernandoAndrade'Html :: activeDropDownList()'가 생산하는 HTML을 게시 할 수 있습니까 (질문을 편집하고 추가합니까)? 그것들을 제대로 벗어나는 문제 ... 당신은 직접 할 수도 있고,'activeDropDownList'의 커스텀 구현으로'HTML'을 오버로드해야 할 수도 있습니다. – prodigitalson
나는 코드를 넣을 때 주석을 편집 할 때 다시 한번 당신이 하루를 많이 보내주었습니다 :) thanks –