Comments (3)
@daftspunk Thanks!
somehow made it work! :))
The problem was from my end not the plugin, as you can see above I am binding the component to a User, here the User is not the Logged in User but the model to update so $this->getUser()
expects an input with the user's identifier and the problem was when the uploader submits the files it was missing an input User which is null - so I wrap the uploader component in a form and added a hidden input with the identifier - it works like a charm - here is what I have in case someone needs to do the same.
Component
public function init()
{
if( !Auth::check() ){
return;
}
$this->account = Auth::getAccount() ;
$this->user = $this->getUser() ;
$this->loadUploader();
}
public function getUser()
{
return Input('user') ? $this->account
->users()
->where ( User::getTableName() .'.'. 'code' , '=' , ( int ) Input('user') )
->first()
: null ;
}
public function loadUploader ()
{
if ( $this->user )
{
$component = $this->addComponent(
'Responsiv\Uploader\Components\FileUploader',
'fileUploader',
[
'deferredBinding' => false,
'fileTypes' => ".jpg, .jpeg, .png, .pdf, .txt, .doc, .xls, .xlsx, .docx, .csv",
]
);
$component->bindModel('attachments', $this->user );
}
}
// Loads a modal with the uploader
public function onGetAttachmentsModal ()
{
$this->pageCycle();
return [
'#attachments-modal' => $this->renderPartial('@attachments', [
'user' => $this->user,
])
];
}
Partial
<div class="row">
<div class="col-sm-12">
{{ form_open({ files: true , model : user }) }}
<input type="hidden" name="user" value="{{user.code}}">
{% component 'fileUploader' %}
{{ form_close() }}
</div>
</div>
from uploader-plugin.
Much success!
from uploader-plugin.
You must load it via the page or the layout, that is so the life cycle knows to look for the upload postback. Partials are not able to do this unfortunately.
https://octobercms.com/docs/cms/partials#life-cycle-limitations
from uploader-plugin.
Related Issues (20)
- Uploader button not working HOT 4
- $(...).render is not a function at uploader.js HOT 10
- [Question] Uploading under same-site subdomain HOT 2
- Trouble in implementing in custom plugin
- Image preview width and height on component does't work. HOT 2
- Multiple instances of Plugin not working. HOT 7
- Validation Extension and Max Size Issue attaching from component HOT 2
- Asset combining not working for addCss and addJs using arrays HOT 5
- files not found HOT 1
- Codeception confused trying to submit the form with uploader HOT 3
- Reorder multiple files?
- using two image-uploaders on single page has issues HOT 1
- sometimes|nullable HOT 2
- Passing additional uploaderOptions to DropZone HOT 6
- chunking with S3
- Files not sorting HOT 1
- imageUploader and fileUploader in the same page not working HOT 3
- IOS "File Missing from request" Error HOT 6
- TypeError: undefined is not an object (evaluating '$.fn') HOT 1
- Vanilla JS / Remove jQuery Dependency HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from uploader-plugin.