Referenced Meta Models with brackets ( ... ) can not be chosen (Error: did not accept the value)
amenk opened this issue · 10 comments
Checklist before I submit this issue report
I confirm that:
- I have tested this with the latest version available (dev)
- I have read documentation @ http://metamodels.readthedocs.org/en/ or http://metamodels.readthedocs.org/de/
- I have checked the Contao community forums for references https://community.contao.org/
- I have checked existing issues for duplicates and found none @ https://github.com/MetaModels/core/issues?q=is%3Aissue%20did%20not%20accept%20the%20value
My environment is:
(Please fill in the actual values from your environment - check Contao Manager or use composer show
)
Key | Value | Comments |
---|---|---|
PHP version: | 8.1 | |
Contao version: | 4.13 | |
MetaModels version: | 2.3@dev | |
Installed MetaModels packages: | almost all | |
DCG version: | 2.3@dev |
Issue description
When selecting a metamodel reference which contains ( )
in the field name, it is not accepted.
Steps to reproduce
- Have to metamodels, one (A) references to another (B)
- in B create an entry with the Name "Frankfurt (Oder)"
- Reference field is the name
- Choose the new entry in A
Describe the behaviour of the application
Message:
Ungültige Auswahl!
Property vita_location (select) did not accept the value (The values differ. Encountered type NULL expected string (Found NULL, expected 'Frankfurt (Oder)')).
Describe the expected behaviour of the application
The form can be saved
Workaround
Rename the entry to "Frankfurt - Oder" and chose it.
Also it might be possible to use the id field as reference instead of the name, but I guess we would need to migrate the references then?
Screenshots
Context
We have this in a Migration project from Countao 4.3 with an older Metamodels version. The data was copied to the new instance - so this might have worked in the older version of Contao / Metamodels.
@amenk Could you check the DB to see how "Frankfurt (Oder)" was saved - as entered or encoded?
Is it possible to select a real alias column for alias as well? It seems to be a MM table...
Is the relation table also multilingual and is "partner_name" multilingual?
- It's saved in encoded form
Frankfurt (Oder)
- Yes it's a MM table -- my first thought was to select the alias or ID as well. But wouldn't we need to migrate the existing relations or does this happen automatically? - also I was not sure if this is an intended limitation and a field like name should just not be possible to use as relation.
- Nothing seems to be multilanguage
Re 2) If I select "id" as the alias column (we don't have an alias) that would work, yes
You should always create an alias for relations - e.g. to have clean URL parameters for filtering.
I assume that the problem is with the encoding - I'll have to create a test case.
You can check this to change Frankfurt (Oder)
to Frankfurt (Oder)
directly in DB
okay, good to know - while I think we don't have filters on this field anyways.
When changing it in the database it does not help - same error.
Also in the Backend Form it selects the first entry after we get the error.
hmm... o.k. - I can can check this after create a test case....
Background info: we have two methods widgetToValue and valueToWidget - when saving, the widgetToValue is executed first to check the value and then the valueToWidget - if the value is the same as the initial value, only then is it saved to the DB - otherwise the error message shown comes up.
The problem is that Contao automatically changes the text when saving it to the database - so Frankfurt (Oder)
becomes Frankfurt (Oder)
The conversion can be switched off in the settings of the attribute of the input mask, so that Frankfurt (Oder)
is saved in the DB.
In MM B, however, we cannot determine which setting was selected for MM A in the input mask or whether there were other conversions.
As written, an alias attribute should also be selected for Alias...
In MM we can't solve the problem - in the future the conversion before storing in the DB from Contao will be omitted - we welcome this very much and hope the "feature" will come in Contao 5
The conversion can be switched off in the settings of the attribute of the input mask, so that Frankfurt (Oder) is saved
in the DB.
I tried to find such a setting in table=tl_metamodel_dcasetting&id=tl_metamodel_dcasetting
of MM A.
But I guess, there just is no other solution than creating an alias for now? I think I misunderstood the answer first :-)
I think we will just create an alias.
save your item with name Frankfurt (Oder) and check the value at DB
Perfect, works :-)