wbraganca / yii2-dynamicform

It is widget to yii2 framework to clone form elements in a nested manner, maintaining accessibility.
Other
433 stars 434 forks source link

yii.jui.AutoComplete #26

Open unpaco opened 9 years ago

unpaco commented 9 years ago

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

hikmat30ce commented 8 years ago

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

hikmat30ce commented 8 years ago

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

penoace commented 8 years ago

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

hikmat30ce commented 8 years ago

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!

penoace commented 8 years ago

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

there are more example for this case?

hikmat30ce commented 8 years ago

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

penoace commented 8 years ago

http://pastebin.com/iq9d3YLw

this my code

hikmat30ce commented 8 years ago

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

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

penoace commented 8 years ago

@aeglesol thanks for reply

but it still error with same masaage.

hikmat30ce commented 8 years ago

have you install the widget correctly!

penoace commented 8 years ago

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

hikmat30ce commented 8 years ago

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

vladjap commented 8 years ago

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

hikmat30ce commented 8 years ago

please check if js for activeformdata is loaded correctly?

vladjap commented 8 years ago

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?

alazgo commented 7 years ago

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

],

]) ?>

hikmat30ce commented 7 years ago

glad to hear that @alazgo

donelson07 commented 6 years ago

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

vladjap commented 6 years ago

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

donelson07 commented 6 years ago

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!

vladjap commented 6 years ago

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

donelson07 commented 6 years ago

@vladjap Thank you!

craiglondon commented 6 years ago

@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

imdad6053 commented 4 years ago

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.

fidels80 commented 4 years ago

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 <?php echo $form->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?