-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
#29026 [Form] fix: selectForForms issue for manage case where objectdesc don't need to reset #30715
base: 19.0
Are you sure you want to change the base?
Conversation
… objectdesc don't need to reset Add preg_match for check before preg_replace Add reset objectdesc to default value
Can you paste the code of ->fields inside the object "session formation" ? |
OK. My understanding is that in your object SessionFormation, you set dynamically the array fields to have the correct definition of the link "Service". Not common, and not designed for initially but why not. However, if we are able to have code working for the link when definition is static, we should be able to have same result (code working) when code is dynamically set, with no need to change code. This is why i think fix is suspicious. fetchObjectByElement(0, strtolower($tmparray[0])); is done with id = 0 because all what we want is an instance of object of the good type (so for you you should get "Product") to be able to reuse later the ->$fields; What do you have for value in |
Here are the values of the variables requested I agree with the fact that defining a fields link statically or dynamically should not lead to modification, but the problem comes from the fresh object, which doesn't use dynamic modification. The fix I'm proposing makes it possible to check that there is a link before making a replacement Otherwise you reset to the initial value $objectdesc => Product L8044 $objectforfieldstmp => Trainingsession Object -> |
@eldy We've change base branch. EDIT: finaly we reset to 19.0 because we prefer wait your input |
OK. The goal of the selectForForms is to use the field key "fk_element" extracted from $objectfield to retreive into trainginsession@dolimeet->fields["fk_element"] what is the object we want for the combo list (the parent object of fk_element. Here, we hope to get Product). Here it fails because selectForForms is calling fetchObjectByElement('trainingsession@dolimeet') to get the parent object from the defintion inside TrainingSession, but fetchObjectbyelement is not working on the dynamic value you modified before, it makes a new $... so the object is a new one and the ->fields inside is also a new one, not modified dynamically, so not in phase. So, for me, the trouble should not be fixed on line 8070, but at the nearest line (the first line) where the deviance appears, so into fetchObjectByElement(), because fetchObjectByElement() return a data with no difference when you made dynamic modifications or not, you are later in the sh.... So later, you introduce some tests to retreive the correct information differently, but with no specific parameter, this let me think this decision will also occurs when it should not. So i suggest to try this: First, I suggest into your trainginsession class file, into ->fields['fk_element'] instead of having This syntax is the one expected by dolibarr now, and the one when generating an object with module builder (except that instead of the name of class you put the hardcoded string "NotPredeclaredClass". Then into the selectForForms, you can change the code
into
This way, it is clear that the test to fallback is only for special cases you are in. Can you try this way ? Note: As this is a developer feature not used in a conventionnel way (it was initially not thinking for dynamic use), we must introduce a solution, but this can only be in develop. |
Field from class we want use selectForForms functions
Error occured because type integer not integer:Product......
Fix with check and reset value
Add preg_match for check before preg_replace
Add reset objectdesc to default value