Are you using the DAO to update the database record after setting the field? Also, there’s $article->setSponsor(), which is preferable to using setData.
Regards,
Alec Smecher
Public Knowledge Project Team
Thank you for your reply! I did not realize that setSponsor() or setData() does not actually execute the SQL but only configures/sets it. Now I see that $articleDao->updateSetting() is required to execute the update for individual settings or $articleDao->updateArticle() to execute all settings. Something like the code below did the job (= deleting all existing sponsors and inserting a new one).
Thanks,
Armin
$existingSponsors = $article->getSponsor(null);
if($existingSponsors) {
foreach (array_keys($existingSponsors) as $locale) {
$article->setSponsor(null,$locale);
$articleDao->updateSetting($article->getId(),'sponsor',array($locale=>null),'string',true );
}
}
$newSponsor = 'The new sponsor';
$locale = 'en_US';
$article->setSponsor($newSponsor,$locale);
$articleDao->updateSetting($article->getId(),'sponsor',array($locale=>$newSponsor),'string',true );