XF 2.3 How to get id of token when using tokeninputrow in form

Basenotes

Well-known member
I'm using a tokeninputrow for a form in which a user can select from a list of brands.

And though I'm able to select the brands and I can see that the ID is being passed via the Ajax call, it does't seem to save the details on form submission.

Not sure if this isn't something that is supported?

Template

HTML:
  <xf:tokeninputrow max-tokens="1" min-length="1" required="required"  name="brand" value="{$object.brand}" href="{{ link('contribute/object-auto-complete', null, {'object_type': 2}) }}" label="Brand"  />

Controller

PHP:
    public function actionObjectAutoComplete()
    {
        // Get the search query and object type
        $q = $this->filter('q', 'str');
        $objectType = $this->filter('object_type', 'int');

        if (strlen($q) >= 2 && $objectType)
        {
            $objectRepo = $this->repository('Basenotes\BasenotesApp:BaseObject');

            // Find objects matching the query and object type
            $objects = $objectRepo->findObjectsByName($q, $objectType, false)
                ->limit(10)
                ->fetch();

            $results = [];
            foreach ($objects AS $object)
            {
                $results[] = [
                    'id' => $object->object_id,
                    'text' => $object->object_name,
                    'q' => $q

                ];
            }
        }
        else
        {
            $results = [];
        }

        $view = $this->view();
        $view->setJsonParam('results', $results);
        return $view;
    }

Only the value gets passed through the form, is there a way of also sending the ID,>
 
Please post a form submission payload example and your code to process that

Here's the payload. I'm not actually processing it yet, as I need to work out how to get the ID :LOL:

Code:
Request Data
MIME Type: application/x-www-form-urlencoded
_xfToken: xxxxx
_xfToken: xxxxx
draft_parent: 0
what: perfume
object[object_name]: No.5
fragrance[concentration]: 1
fragrance[launch][day]: 00
fragrance[launch][month]: 00
fragrance[launch][year]
fragrance[discontinued]: 0
brand: Chanel
 
Back
Top Bottom