Forms, Options, Inputs, and Fun!

Recently, I was asked about using the API to get the list of values for an input. For the record, if you need that list, use the following API endpoint: /api/options/list?optionTypeId=:id This will be on the test later.

When dealing with forms, the inputs now only exist within that form. That is, if you aren’t using existing inputs. For the moment, we’ll pretend we aren’t. Since these options do not appear in the input listing, and even inspecting the element in the web developer console of your browser doesn’t yield an id, we need to do it in a slightly different way. Enter React Developer Tools. You can get that here for Firefox or here for Chromium based browsers.

In the forms dialog, inputs do not have an optionTypeId until you save and exit the form and reopen. Once you do, you’ll see something like the following in the normal inspect:

In the react component viewer in the web developer console, you’ll have to find the element, but they are highlighted as you go through the different components. Eventually, you’ll find the one you want and the key is right there in the react key:

If you select the value underneath it, “z” in this case, I can see the following for my input:

Even better, under the state you find all the names and values:

Now that I have my id, I can use the API call from earlier /api/options/list?optionTypeId=2340:

{
    "success": true,
    "data": [
        {
            "name": "v1.5.2",
            "value": "https://api.github.com/repos/phpipam/phpipam/tarball/refs/tags/v1.5.2"
        },
        {
            "name": "v1.5.1",
            "value": "https://api.github.com/repos/phpipam/phpipam/tarball/refs/tags/v1.5.1"
        },
        {
            "name": "v1.5.0",
            "value": "https://api.github.com/repos/phpipam/phpipam/tarball/refs/tags/v1.5.0"
        },
        {
            "name": "v1.4.7",
            "value": "https://api.github.com/repos/phpipam/phpipam/tarball/refs/tags/v1.4.7"
        },