yii2-dynamicform
yii2-dynamicform copied to clipboard
yii.jui.AutoComplete
Probably has been asked for before, but I would like to request support for adding multiple AutoComplete widgets from the official developers. I tried to code this:
<?= $form->field($modelProducto, "[{$i}]concepto")->widget(yii\jui\AutoComplete::classname(), [
'clientOptions' => [
'source' => ['USA', 'RUS'],
],
'options' => [
'class' => 'form-control',
],
]) ?>
and the first autocomplete field works, but all the others that you try to add don't... Seems like the javascript that attaches the autocomplete functionality to the other fields doesn't update itself or something, as well as, probably, the CSS classes...
I am facing the same issue, is it solved or still pending?
I have solved this issue by customizing the plugin, edited DynamicFormWidget file as attached:
Let me know if some one need more help
@aeglesol i have try your new customize plugin , its still did't work , i got error "yiiActiveFormData is undefined $template.find('.' + yiiActiveFormData.settings.errorCssClass).removeClass(yiiActiveFormData.settings.errorCssClass);"
this is working perfectly for me. also you will need to add assets for jui (autocomplete) and you will have to add new 4 parameters in the DynamicFormWidget .
also please paste you complete error log. also I can help you on skype if you want!
that i got error, than i can't add dynamic form.
there are more example for this case?
can you send me the code in which you have used this widget?
http://pastebin.com/iq9d3YLw
this my code
Check this code: It should work http://pastebin.com/gQYLWzET
also add public $depends = [ 'yii\web\JqueryAsset', ]; in application asset php file
@aeglesol thanks for reply
but it still error with same masaage.
have you install the widget correctly!
yup, cause its normal at basic form, but not for dynamicform + autocomplete
please add "wbraganca/yii2-dynamicform": "*" in composer.json and update composer I doubt it is not install correctly.
i have similar problem, i tried to do what @aeglesol said, but it didn't work. i have yiiActiveFormData is undefined error
please check if js for activeformdata is loaded correctly?
when i open source page there is loaded yii.activeForm.js and yii2-dynamic-form.js... is there any other file that should be loaded?
It works perfect for me. Thanks a lot! hikmat30ce.
'uniqueClass'=>'form-control', //the class 'autocompleteDatasource'=>['USA', 'RUS'], //data source.
= $form->field($model_phistoria, "[{$i}]definition")->widget(yii\jui\AutoComplete::classname(), [ ``` 'clientOptions' => [ 'source' => ['USA', 'RUS'], ], 'options' => [ 'class' => 'form-control', //single class ], ``` ]) ?>
glad to hear that @alazgo
This is a very newbie question, how do you install this new Widget, thanks for your help!. Really appreciated
@donelson It is well explained in readme, if you follow it carefully you will install it properly
Thanks vladjap. I could solve the installation problem, but now I have the issue you reported
Did you find a solution for it? Thanks again!
@donelson07 it was long time ago. I will review it tonight and try to help you. Also, this library is not maintained. There is fork of it that is beeing maintained, and if you are using this in production I would recommend you to switch to that fork.
@vladjap Thank you!
@vladjap @donelson07 I'm surprised this is still an issue (this thread started over two years ago). We just installed this application, followed the example, and are getting the undefined error as well.
We are using PHP 7, Yii 2.0.15.1
@vladjap Which fork do you recommend using?
TypeError: yiiActiveFormData is undefined[Learn More] yii2-dynamic-form.js:90:9
_parseTemplate
We got the same error using dev-master and 2.0.2
hikmat30ce I have the same issue the first autocomplete field works, but all the others that you try to add don't... I updated my Dynamicformwidget.php and my form code is `echo $form->field($model2, "[{$index}]name")->widget(yii\jui\AutoComplete::classname(), [
'clientOptions' => [
'source' => PostName::Datalist(),
],
'options' => [
'class' => 'form-control',
],
]);`
What will I need to change to run autocomplete to all my subChilds.
hi i have the same problem of imdad6053
in the first row of the dynamic form the widget is loaded in the second after i click on add it has been trasformed into text field
here the code
field($m, "[{$i}]itcode")-> //textInput(['maxlength' => true,'placeholder'=>'codice']) widget(\yii\jui\AutoComplete::classname(), [ 'clientOptions' => [ 'source' => $datam[$i], 'autoFill'=>true, // 'id'=>"[{$i}]itcode", 'select' => new JsExpression("function( event, ui ) { $('#invoice-[{$i}]itcode').val(ui.item.id); document.getElementById('invoiceitem-{$i}-item').value=ui.item.label; }") ], ] )->label(false) ?>first row input type="text" id="invoiceitem-0-itcode" name="InvoiceItem[0][itcode]" class="ui-autocomplete-input" autocomplete="off" aria-invalid="false"
second row input type="text" id="invoiceitem-1-itcode" name="InvoiceItem[1][itcode]" aria-invalid="false"
it lost the class any ideas?