processwire-issues
processwire-issues copied to clipboard
Inability to directly set and save changes to multi-value page reference field via a string of IDs
Short description of the issue
$page->of(false);
$page->field_name = '1234|1235';
$page->save('field_name');
won't overwrite existing entries for the field - the newly set values will be appended to existing ones. You need to do:
$page->of(false);
$page->field_name = null;
$page->field_name = '1234|1235';
$page->save('field_name');
or
$page->set('field_name', null);
$page->setAndSave('field_name', '1234|1235');
Expected behavior
Setting the field explicitly, rather than ->remove() and ->add() should remove all existing entries and replace with provided IDs.
Actual behavior
Existing selected page IDs are not automatically removed.