hasOne limits to 10 possibilities in a dropdown?

Does hasOne using mySQL limit the list to 10 selections? I have an application which has a list of accounts, each of which has a type, and for some reason my forms can only see the first 10 matching types.

My Model’s init is pretty straightforward, something like

$this->hasOne(‘accountype’’, new AccountType());

Whenever I throw up a form with that field, I get a dropdown box which works just fine – but I can only see the first 10 types.

Oddly enough, if I go behind the scenes and edit the database directly to make one of the accounts use the 11th type, then when I put up a CRUD I can see the record that references the 11th type just fine. I can even hit the edit button and bring up the record, with the 11th type displyed just fine. But if I edit it within the CRUD editor to change the type, even temporarily (without saving the record), I can’t change it back to the 11th type.

So this seems to have something to do with how the DropDown is creating the list of valid selections. I know it’s not the DropDown form field itself, because in other areas I create DropDown lists using \atk4\ui\FormField\DropDown and I have more than 10 selections in them – but I create those lists from foreach loops, rather than a database query.

However, I’m stumped from here – I’m certainly not doing anything intentionally to limit this, but I can’t figure out what part of Agile Toolkit (or anything it uses) is introducing this limit and, then, what do to about it.

Thanks in advance for any help you can give me.

Hi Sam,

the standard form field for hasOne relationships is Lookup: Its meant for a lot of records as a searchable dropdown. The standard amount of items it displays is 10.

What you can do:

  1. Set the amount of the lookup higher, the property is named “limit”

  2. If you dont have too much account types, you can switch to DropDown. It does not sent extra requests to the server but renders all items on page load. You can do this by setting “ui” property in hasOne definition:

    $this->hasOne(‘accounttype’, [AccountType::class, ‘ui’ => [‘form’ => [‘DropDown’]]]);

Best regards
Philipp

Note I also changed
new AccountType()
to
AccountType::class

Like this, the AccountType Object is only created when really needed.

Thank-you. This was extremely helpful – I’m still learning the Agile Toolkit, and I sometimes have a hard time finding things like this in the docs or going through the code. Is there a place in the documentation / code that I could go to and see all the various properties, and/or possibilities like AccountType::class instead of new AccountType?

On a semi-related note, is there a Field, similar to the Lookup, where I could allow the user to specify a new value? In my original example (as a continuing example), I’d like to give the user to create new account types on the fly. I noticed that the Lookup form was allowing me to type anything, but I can’t figure out how to get my validate hook to access the value in the formfield if it’s not one of the existing IDs.

Thanks,
Sam