I use the uploader plugin to upload pdf files. I have followed the documentation implementing it on the components in the init function. this my following code
public function init(){
$tripFiles = $this->addComponent(
'Responsiv\Uploader\Components\FileUploader',
'tripFiles',
[
'fileTypes' => '.jpg, .jpeg, .png, .pdf, .doc, .docx, .xls, .xlsx, .ppt, .pptx',
'placeholderText' => "Drag and drop file here or Browse File",
],
['deferredBinding' => true]
);
$tripFiles->bindModel('files', ($this->property('tripId') ? Trip::find((int)$this->property('tripId')) : new Trip));
}
public function onSave(){
$data = post();
var_dump($data);
$vacation = new Trip;
$vacation->fill($data);
$vacation->save(null, post('_session_key'));
}
but I found the output with null value on array of _uploader in files.
array:10 [▼
"_handler" => "onCreateXXX"
"_session_key" => "XXXXXXXXXX"
"_token" => "XXXXXXXXXX"
"name" => "XXXXX"
"destination_name" => "XXXX"
"purpose_id" => "1"
"purpose" => ""
"charge_code" => "XXXX"
"city_id" => "1"
"_uploader" => array:1 [▼
"files" => ""
]
]
FrontEnd
{{ form_ajax('onSave')}}
{% component 'tripFiles' %}
<button type="submit" class="btn btn-primary w-90"> Create Trip </button>
{{ form_close() }}
so anyone can help me this problem ??
Here problem is there are 2 models, and yes you wont be able to see file's data in
postI guess.initeither new one or based ontripIdonSaveanyhow not related to model which is binded to the widget ininitmethod.You need to make sure
same modelis used inboth caseso, may be create one variable which can hold model and use that in both scenario.if any doubts please comment.