XF 2.2 Setting a checkbox custom field value

kirsty

Member
I have a custom field which, when I tick the checkbox on the thread manually, appears in the xf_thread_field_value table with
field_idis_imported
field_valuea:1:{s:8:"imported";s:8:"imported";}

If I set the value of this custom field in code using
Code:
'is_imported' => 'a:1:{s:8:"imported";s:8:"imported";}',
however, i end up with an entry in the db that looks exactly the same to me but the checkbox on the thread stays unchecked for that thread. If I go and check it and save then the db looks the same after, but the checkbox is checked on the thread, so something has changed but I can't see what.

Am I missing another part to setting a checkbox custom field value in code?

Thanks.
 
Yeah, you probably want to just use the thread editor service to do this (\XF\Service\Thread\Editor::setCustomFields).
 
Ah, makes sense. Thread\Creator was what I needed. And then you just need to set the field using 'is_imported' => 'imported'.

Thanks!
 
Top Bottom