1. Go to this page and download the library: Download phloxcz/forms-taginput library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
// In your presenter:
$form->addTagInput('tags', 'Tags:')
->setSelection($this->tagRepository->findAll(), 'id', 'name')
->setSearchUrl($this->link('searchTag!'))
->setTheme(TagInput::THEME_BOOTSTRAP)
->setAllowNew(false);
// Signal handler:
public function handleSearchTag(string $q = ''): void
{
$this->sendJson($this['myForm']['tags']->fetchData($q));
}
// Flat array — all values together
$tags = $form['tags']->getValue();
// e.g. [1, 3, "brand new tag"]
// Split by origin
$split = $form['tags']->getSplitValue();
foreach ($split['picked'] as $id) { /* existing record ID */ }
foreach ($split['created'] as $label) { /* new free-text tag */ }
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.