Skip to content

Automaticaly add enctype to the form #114

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

Closed
wants to merge 1 commit into from
Closed

Automaticaly add enctype to the form #114

wants to merge 1 commit into from

Conversation

aadutskevich
Copy link

The same issue as it was with standart yii2 fileInput yiisoft/yii2#8779

The same issue as it was with standart yii2 fileInput yiisoft/yii2#8779
@kartik-v
Copy link
Owner

kartik-v commented May 5, 2017

Will not work here the way the code is written - because this class is not an instance of yii\widgets\ActiveField unlike the yii fileinput which is an activefield instance.

This FileInput widget here can be used with and without a form and via ajax as well... so it makes sense for users to set the enctype property to the form based on their own need (as it is not mandatory for the other cases like ajax).

@aadutskevich aadutskevich deleted the patch-1 branch May 5, 2017 11:54
@aadutskevich aadutskevich restored the patch-1 branch May 5, 2017 11:55
@aadutskevich
Copy link
Author

Ok, let we add an instance check, So if we use widget with ActiveField then the form enctype option will be created.

    `if ($this->field instanceof \yii\widgets\ActiveField && !isset($this->field->form->options['enctype'])) {
	    $this->field->form->options['enctype'] = 'multipart/form-data';
    }`

@kartik-v
Copy link
Owner

kartik-v commented May 5, 2017

Ok -- this above code will work for InputWidget... will figure out and include this...

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

Successfully merging this pull request may close these issues.

2 participants