Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set required (must be set) on upload form #37

Open
adiramardiani opened this issue Feb 11, 2016 · 4 comments
Open

How to set required (must be set) on upload form #37

adiramardiani opened this issue Feb 11, 2016 · 4 comments

Comments

@adiramardiani
Copy link

In rule is provided FileValidator, how to add a required option ?

/*example*/
[['field_name'], 'required', 'on' => 'update'],
@CTOlet
Copy link
Owner

CTOlet commented Feb 15, 2016

Does it work if you set the rules inside app config?

'modules' => [
    ...
    'attachments' => [
        'class' => nemmo\attachments\Module::className(),
        'rules' => [ // Rules according to the FileValidator
            'maxFiles' => 10, // Allow to upload maximum 3 files, default to 3
            'mimeTypes' => 'image/png', // Only png images
            'maxSize' => 1024 * 1024 // 1 MB
        ],
    ]
    ...
]

But I think it will not work. Thus it will be an enhancement. Added to checklist #36

@adiramardiani
Copy link
Author

Yes I did not try it inside the app config
But what kind of method that can do that ?

It's so I need at this moment, if you could explain a temporary method that allows this currently ? while I waited for the enhancement

Thanks

@CTOlet
Copy link
Owner

CTOlet commented Feb 15, 2016

You can fork or download the whole module and add this feature inside file behavior. I think the right way is to check the file existance on before save event

@adiramardiani
Copy link
Author

Sorry, add this feature inside file behavior or check the file existance on before save event, I can't understand how to write it, I was newbie, can you also explain the example code.

(While waiting in the newest version for the best method)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants