PHP code example of kreemer / ux-autocomplete-js

1. Go to this page and download the library: Download kreemer/ux-autocomplete-js 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/ */

    

kreemer / ux-autocomplete-js example snippets


// ...
use Kreemer\UX\AutoCompleteJS\Builder\AutoCompleteBuilderInterface;

class IndexController extends AbstractController
{
    /**
     * @Route("/", name="homepage")
     */
    public function index(AutoCompleteBuilderInterface $autoCompleteBuilder): Response
    {
        $autoComplete = $autoCompleteBuilder->createAutocomplete();
        $autoComplete->getDataModel()->setSrc([ 'here', 'are', 'the', 'options']);

        return $this->render('index/index.html.twig', [
            'autoComplete' => $autoComplete,
        ]);
    }
}

$form = $this->createFormBuilder($array)
    ->add('user', AutoCompleteType::class, [
        'class' => User::class,
        'choice_label' => 'name',
    ])
    ->add('save', SubmitType::class, ['label' => 'Submit'])
    ->getForm();
sh
php vendor/bin/phpunit