Please, is it possible for an Autocomplete ( or Look Up ) form field to accept a value that it is not in the dropdown list ? I am aware of the ‘plus’ flag but what I need is to be able to accept that value even if not in the list ?
Thanks in advance for your attention,
ModelA->hasOne('b_id', ModelB::class); then your data persistence will only validate when field is provided with a correct reference.
Form will show this using auto-complete but will actually be saving “ID” of related model. That’s why the AutoComplete field is configured not to accept values that are not on the list.
There is “AutoComplete Plus”: http://ui.agiletoolkit.org/demos/autocomplete.php (with Add New) label, allowing you to create new related element. This is safer than letting user type name of related item and create it only with this name (as it might not work in situations when related element has other important fields).
You should be able to implement this functionality with a custom field. Create a form, add field decorator to the form, manually supply autocomplete callback functionality - there are probably ways to do that.
However, seeing as you are new to ATK - try using the “Plus” for adding new elements even if it’s not the most user-friendly. Gradually as you become more experienced, you’ll be able to implement new decorators correctly.