Closed skeeran closed 9 years ago
I'm working on it now. At the moment works well with MasKmoney, Fileinput, Touchspin and Datepicker.
first of thanks for your response, waiting for the updates.. hoping for a fast release :D
Amazing you have already updated with select2 widget. Waiting for typeahead :D
Hello,
For some reason kartik select2 doesn't work in my configuration.
I have this:
$countrylist = ArrayHelper::map(Countries::find()->orderBy('country_id')->all(), 'country_id', 'country_name');
<?php DynamicFormWidget::begin([
'dynamicItems' => '#form-qualifications',
'dynamicItem' => '.form-qualifications-item',
'model' => $modelsQualifications[0],
'formId' => 'registration-step-1',
'formFields' => [
'employee_employment_position',
'employee_employment_start_date',
'employee_employment_end_date',
'employee_employment_reason',
'employee_employment_organisation',
'employee_employment_town',
'employee_employment_country',
],
'options' => [
'limit' => 4, // the maximum times, an element can be cloned (default 999)
]
]); ?>
<?php
echo $form->field($modelQualifications, '[]employee_employment_country')->widget(Select2::classname(), [
'data' => $countrylist,
'options' => ['placeholder' => 'Select country ...'],
'pluginOptions' => [
'allowClear' => true
],
]);
?>
I get the following when I click on [+](see Employee Qualification Country)
Thank you!!
Index of the attribute can not be empty.
Change:
'[]employee_employment_country'
To
"[{$index}]employee_employment_country"
Hello,
Changed that to
<?php
echo $form->field($modelQualifications, '['.$i.']employee_employment_country')->widget(Select2::classname(), [
'data' => $countrylist,
'options' => ['placeholder' => 'Select country ...'],
'pluginOptions' => [
'allowClear' => true
],
]);
?>
Whole code:
<?php
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\helpers\URL;
use frontend\models\TitlesList;
use frontend\models\Yesorno;
use frontend\models\Countries;
use frontend\models\EmployeeEmployment;
use wbraganca\dynamicform\DynamicFormWidget;
use yii\bootstrap\Modal;
use kartik\widgets\ActiveForm;
use kartik\widgets\DatePicker;
use kartik\widgets\Select2;
?>
<?php
$form = ActiveForm::begin(['id'=>'registration-step-1','options'=>['class'=>'form-block']]);
?>
<?php
$titleslist = ArrayHelper::map(TitlesList::find()->orderBy('title_order')->all(), 'title_id', 'title_name');
$yesornolist = ArrayHelper::map(Yesorno::find()->orderBy('yesorno_order')->all(), 'yesorno_id', 'yesorno_name');
$countrylist = ArrayHelper::map(Countries::find()->orderBy('country_id')->all(), 'country_id', 'country_name');
?>
<?= Html::activeDropDownList($modelEmployee, 'employee_title', $titleslist, array('class'=>'form-control','prompt'=>'Please Select Title')) ?>
<?= $form -> field ($modelEmployee,'employee_firstname') ?>
<?= $form -> field ($modelEmployee,'employee_lastname') ?>
<?= $form -> field ($modelEmployee,'employee_workpermit')->radiolist($yesornolist,['itemOptions' => ['class' =>'radio-inline']]) ?>
<p>Contact Information</p>
<?= $form -> field ($modelEmployee,'employee_email') ?>
<?= $form -> field ($modelEmployee,'employee_phone') ?>
<?= $form -> field ($modelEmployee,'employee_mobile') ?>
<?= $form -> field ($modelEmployee,'employee_address') ?>
<?= $form -> field ($modelEmployee,'employee_town') ?>
<?= $form -> field ($modelEmployee,'employee_country') ?>
<?= $form -> field ($modelEmployee,'employee_postcode') ?>
<p>Education</p>
<?
//echo $form -> field ($modelEmployee,'employeeQualifications')
?>
<?php DynamicFormWidget::begin([
'dynamicItems' => '#form-qualifications',
'dynamicItem' => '.form-qualifications-item',
'model' => $modelsQualifications[0],
'formId' => 'registration-step-1',
'formFields' => [
'employee_employment_position',
'employee_employment_start_date',
'employee_employment_end_date',
'employee_employment_reason',
'employee_employment_organisation',
'employee_employment_town',
'employee_employment_country',
],
'options' => [
'limit' => 5,
]
]); ?>
<div id="form-qualifications">
<?php foreach ($modelsQualifications as $i => $modelQualifications): ?>
<div class="form-qualifications-item panel panel-default">
<div class="panel-heading">
<h3 class="panel-title pull-left">Qualifications</h3>
<div class="pull-right">
<button type="button" class="clone btn btn-success btn-xs"><i class="glyphicon glyphicon-plus"></i></button>
<button type="button" class="delete btn btn-danger btn-xs"><i class="glyphicon glyphicon-minus"></i></button>
</div>
<div class="clearfix"></div>
</div>
<div class="panel-body">
<?php
// necessary for update action.
if (!$modelQualifications->isNewRecord) {
echo Html::activeHiddenInput($modelQualifications, "[{$i}]id");
}
?>
<?= $form->field($modelQualifications, "[{$i}]employee_employment_position")->textInput(['maxlength' => 64]) ?>
<div class="row">
<div class="col-sm-6">
<?php
echo $form->field($modelQualifications, "[{$i}]employee_employment_start_date")->widget(DatePicker::classname(), [
'options' => ['placeholder' => 'Please enter employment start date'],
'pluginOptions' => [
'autoclose'=>true,
'format' => 'dd/mm/yyyy'
]
]);
?>
</div>
<div class="col-sm-6">
<? //$form->field($modelQualifications, "[{$i}]employee_employment_end_date")->textInput(['maxlength' => 128]) ?>
<?php
echo $form->field($modelQualifications, "[{$i}]employee_employment_end_date")->widget(DatePicker::classname(), [
'options' => ['placeholder' => 'Please enter employment end date'],
'pluginOptions' => [
'autoclose'=>true,
'format' => 'dd/mm/yyyy'
]
]);
?>
</div>
</div><!-- .row -->
<div class="row">
<div class="col-sm-4">
<?= $form->field($modelQualifications, "[{$i}]employee_employment_reason")->textInput(['maxlength' => 64]) ?>
</div>
<div class="col-sm-4">
<?= $form->field($modelQualifications, "[{$i}]employee_employment_organisation")->textInput(['maxlength' => 32]) ?>
</div>
<div class="col-sm-4">
<?= $form->field($modelQualifications, "[{$i}]employee_employment_town")->textInput(['maxlength' => 15]) ?>
</div>
<div class="col-sm-4">
<?php
echo $form->field($modelQualifications, "[{$i}]employee_employment_country")->widget(Select2::classname(), [
'data' => $countrylist,
'options' => ['placeholder' => 'Select country ...'],
'pluginOptions' => [
'allowClear' => true
],
]);
?>
</div>
</div><!-- .row -->
</div>
</div>
<?php endforeach; ?>
</div>
<?php DynamicFormWidget::end(); ?>
<p>Employment in the last two years</p>
<p>Languages</p>
<p>Additional information</p>
<div class="form-group">
<?= Html::submitButton('Submit', ['class' => 'btn btn-primary']) ?>
</div>
<?php
ActiveForm::end();
?>
still doesn't work.
Ensure that you are using the latest version of "Select2" and "yii2-dynamicform".
i update latest version but still not working
hi, is this extension now working for typehead?
Hello,
thanks for your nice yii2-dynamicform.
Unfortunately even for me typeahead is not working in a dynamicform field.
Do you have any plan about it?
Thanks in advance
@dariopalmisano check this file: https://github.com/vilkh3m/yii2-dynamicform/blob/master/src/assets/yii2-dynamic-form.js and compare with your code lines from 457 to 465 this fix my problem
and i need use symfony/css-selector and symfony/dom-crawler in version 2.6.6, this don work on version 2.7.* but im unable to use this via composer :( i just copy code from github
Thanks vilkh3m for your quick response.
Unfortunately I had already applied that patch to make yii2-widget-select2 work in a yii2-dynamicform field!
Regards
Dear your problem solved or not? I faced same problem. Did you find typehead dynamic form solution?
Dear your problem solved or not? I faced same problem. Did you find typehead dynamic form solution?
did you try this: https://github.com/wbraganca/yii2-dynamicform/pull/292/commits/aeff3d0d18fb1c515f64db6d5e6052074264937e ?
Hi, i was looking for somthing like this...
but this only works with basic html input fields... not with yii2 known select2(https://github.com/kartik-v/yii2-widget-select2) or Typeahead(https://github.com/kartik-v/yii2-widget-typeahead) etc..
Fot the first row it is working.. secound row is not loading properly... you have any solution or tips to get this to work