fix(custom-fields) : match by orderIndex to prevent value loss on rename
When a ModelType's custom field was renamed without sending the field ID, the service would create a new CustomField instead of reusing the existing one, orphaning all CustomFieldValues. Now matches by orderIndex as fallback before name, preserving the link to existing values. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -382,6 +382,8 @@ abstract class AbstractApiTestCase extends ApiTestCase
|
||||
string $value = 'test value',
|
||||
?Machine $machine = null,
|
||||
?Composant $composant = null,
|
||||
?Piece $piece = null,
|
||||
?Product $product = null,
|
||||
): CustomFieldValue {
|
||||
$cfv = new CustomFieldValue();
|
||||
$cfv->setValue($value);
|
||||
@@ -392,6 +394,12 @@ abstract class AbstractApiTestCase extends ApiTestCase
|
||||
if (null !== $composant) {
|
||||
$cfv->setComposant($composant);
|
||||
}
|
||||
if (null !== $piece) {
|
||||
$cfv->setPiece($piece);
|
||||
}
|
||||
if (null !== $product) {
|
||||
$cfv->setProduct($product);
|
||||
}
|
||||
|
||||
$em = $this->getEntityManager();
|
||||
$em->persist($cfv);
|
||||
|
||||
Reference in New Issue
Block a user