-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
AttributeValue __toString() invalid #3914
Comments
Although it looks like the new model for attributes is still expecting __toString() to work: Also this looks broken 'oldhref' so if someone is going to look at this: https://github.com/Sylius/Sylius/blob/master/src/Sylius/Bundle/AttributeBundle/Resources/views/attributeChoice.html.twig#L13 I'm not sure how well tested this is with datetimes, but maybe a twig function is required to render attribute values, because casting like this won't work. |
OK cool, looks like some nice improvements there but doesn't solve the underlying issues around types. |
Sure it was a bit off topic, just for the oldhref thingy |
@peteward about this file I think it's confusing naming, because This issue is because of preliminary attribute display system: for now, specific attribute type template is sought here and if it does not exist, attribute is rendered with default Sure, we should discuss how attributes should be rendered - should it be twig extension, or maybe |
So I guess we should simply remove the |
Sure, |
Hi Mateuz, Thanks for linking this through, it makes more sense now. I'm getting exceptions in a FormType due to __toString() but I think this could be due to code for the legacy attributes model clashing with the new model - I will check this tonight. Perhaps it would be good to wrap this up in a twig filter or function?
Although surrounding mark-up could be different in some cases, this feels like the basic rendering of the type could be consistent across places that you want to render it? As for the Attribute-which-is-really-AttributeValue issue... @michalmarcinkowski brought this one up recently. I agree with him that I think this should be renamed on the product object to attributeValue, not attribute. I know that attributeValue.value seems like duplication but this is the way the model works, renaming it to attribute to try and hide this feels like it causes more headaches. I'll get back to you on my exception - it's probably a problem ay my end then this one can be closed. |
@peteward I do not recall any place in Sylius where __toString would be called on AttributeValue, we don't have any select forms with values I believe. Let me know if you find the issue, I'll be glad to help! |
Yep, problem my end not using the new Removing __toString() looks good. |
Since the value is typed this no longer works. You could cast with (string) but this probably won't have the desired affect on date fields so it should probably just be removed?
https://github.com/Sylius/Sylius/blob/master/src/Sylius/Component/Attribute/Model/AttributeValue.php#L75
The text was updated successfully, but these errors were encountered: