S
S
Semen2020-02-12 19:10:42
Yii
Semen, 2020-02-12 19:10:42

The attribute from krajee-DateControl is not passed to the model?

I am using krajee's DateControl widget to enter the date of birth (birthday)

<?= $form->field($model, 'birthday')->widget(DateControl::className(), [
    'type' => DateControl::FORMAT_DATE,
    'widgetOptions' => [
    'options' => ['placeholder' => 'Выберите дату ...'],
                'layout' => '<div class="input-group"><span class="input-group-addon">Д.рождения</span>{input}</div>',
                 'pluginOptions' => [
                          'todayHighlight' => true,
                           'autoclose' => true
                ]
        ]
])->label(false); ?>

date is passed to the widget by ajax
$('#buttonStart').on('click', function(){
   	$.ajax({
    url: 'create',
    method: 'POST',
      async: false,
    data: {text:$('#n').val()},
        success: function(data) {
        $('#man-birthday-disp').val(data.birthday);
        console.log();		   
  },
        error:function() {
           console.log("error");
        }
  });
});

The date is displayed on the form normally, but when saving the model is passed to the controller with an empty birthday attribute.
Do not understand why?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Semen, 2020-02-13
@Semen-29

The form has a field for selecting a date - a DateControl widget with id = "man-birthday-disp".
The user enters the id-record, clicks on the button and ajax gets the full name and date of birth from the database. The data in the form fields comes normally, i.e. after clicking the fill by id button, the date of birth appears in the DateControl field, but after clicking save, the model with an empty birthday attribute leaves the controller. As if there is nothing in the DateControl. Why?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question