yii2-dynamicform icon indicating copy to clipboard operation
yii2-dynamicform copied to clipboard

yii.jui.AutoComplete

Open unpaco opened this issue 9 years ago • 25 comments

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...

unpaco avatar Mar 29 '15 01:03 unpaco

I am facing the same issue, is it solved or still pending?

hikmat30ce avatar Jan 30 '16 20:01 hikmat30ce

I have solved this issue by customizing the plugin, edited DynamicFormWidget file as attached:

DynamicFormWidget.zip

Let me know if some one need more help

hikmat30ce avatar Jan 31 '16 18:01 hikmat30ce

@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);"

penoace avatar Feb 01 '16 05:02 penoace

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!

hikmat30ce avatar Feb 01 '16 07:02 hikmat30ce

eror that i got error, than i can't add dynamic form.

there are more example for this case?

penoace avatar Feb 01 '16 08:02 penoace

can you send me the code in which you have used this widget?

hikmat30ce avatar Feb 01 '16 10:02 hikmat30ce

http://pastebin.com/iq9d3YLw

this my code

penoace avatar Feb 01 '16 11:02 penoace

Check this code: It should work http://pastebin.com/gQYLWzET

also add public $depends = [ 'yii\web\JqueryAsset', ]; in application asset php file

hikmat30ce avatar Feb 01 '16 13:02 hikmat30ce

@aeglesol thanks for reply

but it still error with same masaage.

penoace avatar Feb 02 '16 05:02 penoace

have you install the widget correctly!

hikmat30ce avatar Feb 02 '16 05:02 hikmat30ce

yup, cause its normal at basic form, but not for dynamicform + autocomplete

penoace avatar Feb 02 '16 06:02 penoace

please add "wbraganca/yii2-dynamicform": "*" in composer.json and update composer I doubt it is not install correctly.

hikmat30ce avatar Feb 02 '16 06:02 hikmat30ce

i have similar problem, i tried to do what @aeglesol said, but it didn't work. i have yiiActiveFormData is undefined error

vladjap avatar Mar 17 '16 21:03 vladjap

please check if js for activeformdata is loaded correctly?

hikmat30ce avatar Mar 18 '16 05:03 hikmat30ce

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?

vladjap avatar Mar 18 '16 11:03 vladjap

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 ], ``` ]) ?>

alazgo avatar Sep 25 '16 18:09 alazgo

glad to hear that @alazgo

hikmat30ce avatar Sep 25 '16 18:09 hikmat30ce

This is a very newbie question, how do you install this new Widget, thanks for your help!. Really appreciated

donelson07 avatar Jun 04 '18 20:06 donelson07

@donelson It is well explained in readme, if you follow it carefully you will install it properly

vladjap avatar Jun 04 '18 21:06 vladjap

Thanks vladjap. I could solve the installation problem, but now I have the issue you reported image

Did you find a solution for it? Thanks again!

donelson07 avatar Jun 05 '18 16:06 donelson07

@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 avatar Jun 06 '18 13:06 vladjap

@vladjap Thank you!

donelson07 avatar Jun 06 '18 17:06 donelson07

@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

craiglondon avatar Jun 08 '18 21:06 craiglondon

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.

imdad6053 avatar Dec 15 '19 20:12 imdad6053

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?

fidels80 avatar Apr 03 '20 10:04 fidels80