Error returning checkboxes

Hey guys,

I have an user field preferences which is a string: Pref1, Pref2, Pref3.

I’m trying to return this in a list of checkboxes, as described in the docs:

<?php foreach($user->preferences()->split(', ') as $pref): ?>
                        <fieldset>
                            <?php echo html($pref) ?>
                        </fieldset>
                    <?php endforeach ?>

But I’m getting this error:
Call to a member function split() on string

Isn’t the split() supposed to get called on a string?

Would love some help!

The user fields returns a string, whereas a page field returns an object of type field.

For user fields, you therefore have to use a standard PHP function, in this case explode(): http://php.net/manual/de/function.explode.php