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
Controller
Only the value gets passed through the form, is there a way of also sending the ID,>
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,>