# 2 years, 5 months ago

    Ok, I’m going crazy.. 😀

    Serializing the array is indeed correct, actually I don’t know where to put the function to convert the array.
    What I basically need is an input in my form, to select multiple choices and save those choices – the view has to be capable of interpreting the saved data and convert ‘user-2’ to ‘John Smith’.

    So far I managed to select multiple choices taking the data from users and groups table:
    ‘choices’ => FormHelper::downByChoises()
    public static function downByChoises()

    $users = User::where(‘company_id’,’=’,Landlord::getTenants()->first())->get();
    $groups = Group::where(‘company_id’,’=’,Landlord::getTenants()->first())->get();
    $users = User::all();
    $groups = Group::all();

    $options = [
    trans(‘core::core.form.optgroup.users’) => $users->mapWithKeys(function ($item) {
    return [‘user-‘ . $item[‘id’] => $item[‘name’]];
    trans(‘core::core.form.optgroup.groups’) => $groups->mapWithKeys(function ($item) {
    return [‘group-‘ . $item[‘id’] => $item[‘name’]];

    return $options;

    I’m not sure in the controller how to configure this:
    protected $showFields = [
    ‘down_by’ => [‘type’ => ‘manyToMany’, ‘column’ => ‘name’, ‘relation’ => [‘users’,’groups’], ‘col-class’ => ‘col-lg-4’],
    ‘notify_by’ => [‘type’ => ‘manyToMany’, ‘column’ => ‘name’, ‘relation’ => [‘users’,’groups’], ‘col-class’ => ‘col-lg-4’]

    I’m not sure what type to use.
    oneToMany, manyToMany, manyToOne are giving me errors related to relations.

    The thing is: these two fields have to save users name and group name.
    Do I need a specific relation? Or it is sufficient a text type? With a json saved into ?


    have a nice day.