(function(e) {
$('#ajax-upload').on('change', function() {
var url = $(this).attr('data-action');
var fd = new FormData();
console.log(this.files);
fd.append("UploadForm[file]", this.files[0]);
$.ajax({
url: url,
type: "POST",
data: fd,
processData: false,
contentType: false,
dataType: 'json',
success: function(response) {
if (response.success) {
$('#post-image_url').val(response.url);
$('img#thumb').attr('src', response.url);
}
}
});
});
}());
function utf8_strrev($str){
preg_match_all('/./us', $str, $ar);
return join('',array_reverse($ar[0]));
}
<?= AutoComplete::widget([
'name' => 'client',
'id' => 'client-find',
'options' => [
'class' => 'form-control',
],
'clientOptions' => [
'source' => MemberUser::find()
->select(['concat( lastname, " ", firstname ) as label', 'concat( lastname, " ", firstname ) as value', 'id as id'])
->asArray()
->all(),
'autoFill' => false,
'minLength' => 2,
'select' => new yii\web\JsExpression("function( event, ui ) {
console.log(ui.item);
document.getElementById('eventsuser-client').value = ui.item.id;
document.getElementById('client-find').value = ui.item.label;
}")
]
]); ?>
class User implements IdentityInterface
{
...
}