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
Fix for typed attributes in BaseHtml::activeListInput()
#19447
base: master
Are you sure you want to change the base?
Conversation
WinterSilence
commented
Jun 15, 2022
•
edited
edited
Q | A |
---|---|
Is bugfix? | ✔️ |
New feature? | ❌ |
Breaks BC? | ❌ |
Fixed issues | #19446 |
Thank you for putting effort in the improvement of the Yii framework. In order for the framework and your solution to remain stable in the future, we have a unit test requirement in place. Therefore we can only accept your pull request if it is covered by unit tests. Could you add these please? Thanks! P.S. If you have any questions about the creation of unit tests? Don't hesitate to ask for support. More information about unit tests This is an automated comment, triggered by adding the label |
BaseHtml::activeListInput()
BaseHtml::activeListInput()
@samdark test added |
This does not fix this error, it hides it (unselect no longer works). I don't think it is worth to fix #19446, since by design you should not use typed propertied (or setters) for form models. In Yii 2 validation has 2 steps:
Therefore, your model must accept any data type for validation to work. |
"unselect" not works when user don't want it and strictly declare attribute/property as array. this method should have created hidden input for each checkbox to keep data type.
Nonsense, by your logic, adaptation to PHP8 is also not needed. 10 years ago typing was just beginning to be introduced into PHP - it's not "desing", just wasn't any other solutions to data typing. |
@WinterSilence maybe it would be more appropriate to handle this by |
@MarkoNV Yii 2 is freezed i.e. just fixes are allowed |
@WinterSilence I think we had disagreement about cause of #19446. Your view is that setting Solution would be:
If we conclude that first solution would be new feature, we end up on what @rob006 said. Also, your solution is BC break. You are changing behavior of Example casting/filtering on load:
This example is valid project code, works with current implementation and allows unsetting properties with default Example proxy property:
View:
This is also valid project code. As I said, that should be solved by casting on loading data. Solving it on framework level would be nice, but if you consider it new feature, then only documentation should be changed explaining limitations, consequences and possible solutions for typed attributes. |
nope, in this case the old version throws an exception
|
Example from bug report throws exception because property doesn't accepts all possible values from user. In my two examples, there is no exception because model implementation handles accepting values from user and by default there is possibility to unselect, as is per documentation. After your PR, ability to unselect is by default disabled unless manually enabled, which is BC break.
This submission should set property to empty value:
but this submission shouldn't change property
Both submissions match |