How to change the date format of jui date picker in yii2

Hi,
I am using Yii2 basic. I am using a dynamic form widget. This is required so that I can store multiple data values of a two models. I have a form where I have a date field and using a jui date picker. On dynamic form I have made changes so that every time the user clicks on + button a new row is displayed for data entry. For the first record, the date picker displayes the correct date format but on second row onwards, the date format changes.
Below is the form code.

<?php

use yii\helpers\Html;

use yii\bootstrap\ActiveForm;
//use nex\datepicker\DatePicker;
use yii\web\UploadedFile;
use yii\jui\DatePicker;
use wbraganca\dynamicform\DynamicFormWidget;
use yii\web\JsExpression;

?>


<b><font size="3">A) Missional</font></b>

<?php DynamicFormWidget::begin([
    'widgetContainer' => 'dynamicform_inner',
    'widgetBody' => '.container-missional',
    'widgetItem' => '.missional-item',
    'limit' => 7,
    'min' => 1,
    'insertButton' => '.add-missional',
    'deleteButton' => '.remove-missional',
    'model' => $modelsShortTermMissional[0],
    'formId' => 'dynamic-form',
    'formFields' => [
        'Particulars',
		'Priority',

		'TargetDate',
    ],
]); ?>
<table class="table table-bordered">
    <thead>
        <tr bgcolor='#B8B8B8'>
            <th style='border: 1px solid black;'></th>
                <th class ="text-center" style='border: 1px solid black;'>Particulars</th>
                <th class ="text-center" style='border: 1px solid black;'>Priority</th>
				<th class ="text-center" style='border: 1px solid black;'>Target Date</th>
				
            <th class="text-center" style='border: 1px solid black;'>
                <button type="button" class="add-missional btn btn-success btn-xs"><span class="glyphicon glyphicon-plus"></span></button>
            </th>
        </tr>
    </thead>
    <tbody class="container-missional">
    <?php foreach ($modelsShortTermMissional as $indexMissional => $modelShortTermMissional): ?>
        <tr class="missional-item">
            <td class="vcenter" style='border: 1px solid black;'>
                <?php
                    // necessary for update action.
                    if (! $modelShortTermMissional->isNewRecord) {
                        echo Html::activeHiddenInput($modelShortTermMissional, "[{$indexShortTerm}][{$indexMissional}]ShortTermMissionalGoalId");
                    }
                ?>
				</td>
				<td style='border: 1px solid black; width:30%'>
                <?= $form->field($modelShortTermMissional, "[{$indexShortTerm}][{$indexMissional}]Particulars")->label(false)->textInput(['maxlength' => true]) ?>
            </td>
			<td style='border: 1px solid black; width:30%'>
                <?= $form->field($modelShortTermMissional, "[{$indexShortTerm}][{$indexMissional}]Priority")->label(false)->textInput(['maxlength' => true]) ?>
            </td>
			<td style='border: 1px solid black; width:30%'>
                <?= $form->field($modelShortTermMissional, "[{$indexShortTerm}][{$indexMissional}]TargetDate")->label(false)->widget(\yii\jui\DatePicker::classname(), [
                                            //'language' => 'ru',
                                            'dateFormat' => "yyyy-MM-dd",
                                            'options' => ['class' => 'form-control picker']
]) ?>
            </td>
            <td class="text-center vcenter" style=" border: 1px solid black;width: 90px;">
                <button type="button" class="remove-missional btn btn-danger btn-xs"><span class="glyphicon glyphicon-minus"></span></button>
            </td>
        </tr>
     <?php endforeach; ?>
    </tbody>
</table>

<?php DynamicFormWidget::end(); ?>


Also in js file of dynamic form widget I have added the below code

$(function () {
    $(".dynamicform_inner").on("afterInsert", function(e, item) {
         $( ".picker" ).each(function() {
            $( this ).datepicker({
            dateFormat : 'yy-mm-dd',
            language : 'en',
            changeMonth: true,
            changeYear: true
          });
        });
    });
});

How should I change the format of date appearing from second row?

Hi,
you could render the new input by Ajax .
It Will be more effective as you don’t have to worry about js to manipulate the new instance of datepicker. Simply by an onclick event you can render new row (from an action controller)and so a new instance of the datepicker formatted as you need.
M