Dependencies
$nodeAutoComplete = $k->nodeAutoComplete('foo_node')
->setTitle($this->t('Foo Node'))
->setTargetBundle('foo')
->setCondition(
$q->condition('status')->is()
)
->setCondition(
$q->condition('field_bar')->isIn(['x', 'y', 'z'])
);
- The example above relies on the query service provided by query module. You will need to inject the service into your form & set the $q variable accordingly.
- Node filtering is provided by query module's NodeByFieldSelection class.
- If you do not wish to use the query service, you can use NodeAutoCompleteKit::setFilter method instead:
$nodeAutoComplete = $k->nodeAutoComplete('foo_node') ->setTitle($this->t('Foo Node')) ->setTargetBundle('foo') ->setFilter('status', 1)