IgorKorytin

Untitled

Aug 16th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.14 KB | None | 0 0
  1.     <?php    
  2.             echo $form->select2Row($model, 'contract_id', [
  3.                 'data' => [],
  4.                 'multiple' => false,
  5.                 'id' => 'contract',
  6.                         'required' => true,    
  7.                 'empty' => '',
  8.                 'ajax' => [
  9.                     'type' => 'POST',
  10.                     'dataType' => 'json',
  11.                     'url' => CController::createUrl('Request/services'),
  12.                     'success' => 'function(data) {
  13.                                    var newOptions = "";
  14.                                    var services = data.services;
  15.                                    console.log(services);
  16.                                    $.each(services, function(index, value){
  17.                                        newOptions += "<option value=" + value.id + ">"  + value.text + "</option>";
  18.                                    });
  19.                                    $("#service").select2("destroy").html(newOptions).select2();
  20.                                    $("#service").select2().select2({"width":"220px"});
  21.                                }',
  22.                 ]
  23.             ]);?>
Advertisement
Add Comment
Please, Sign In to add comment