# How to implement SelectRequestOptions in repeater?

**URL:** <https://discourse.getcockpit.com/t/how-to-implement-selectrequestoptions-in-repeater/1883>\
**Category:** Support\
**Created:** [March 23, 2021, 5:16am UTC](https://discourse.getcockpit.com/t/how-to-implement-selectrequestoptions-in-repeater/1883 "2021-03-23T05:16:16Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![dhanjiv](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@dhanjiv](https://discourse.getcockpit.com/u/dhanjiv)\
**Post date:** [March 23, 2021, 5:16am UTC](https://discourse.getcockpit.com/t/how-to-implement-selectrequestoptions-in-repeater/1883/1 "2021-03-23T05:16:17Z")

</div>

Any one help me here. how to implement SelectRequestOptions in repeater

---

<div class="post-metadata">

**Author:** ![raffaelj](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/raffaelj/32/331_2.png) [@raffaelj](https://discourse.getcockpit.com/u/raffaelj)\
**Post date:** [March 23, 2021, 9:25am UTC](https://discourse.getcockpit.com/t/how-to-implement-selectrequestoptions-in-repeater/1883/2 "2021-03-23T09:25:21Z")

</div>

What’s your goal? Both field types have multiple possible data models, so your question is a bit too generic.

---

<div class="post-metadata">

**Author:** ![dhanjiv](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@dhanjiv](https://discourse.getcockpit.com/u/dhanjiv)\
**Post date:** [March 23, 2021, 9:29am UTC](https://discourse.getcockpit.com/t/how-to-implement-selectrequestoptions-in-repeater/1883/3 "2021-03-23T09:29:57Z")

</div>

I am trying to call SelectRequestOptions in repeater that not connecting but calling without repeater is working , i have written custom code to fetch category dynamically after custom code calling in repeater se bellow code:

```json
{
  "field": {
    "type": "set",
    "label": "Category",
    "options": {
      "fields": [
        {
          "request": "/category-custom",
          "value": "categoryName",
          "label": "categoryName",
          "multiple": false
        },
        {
          "name": "question",
          "type": "repeater",
          "label": "Question",
          "options": {
            "field": {
              "type": "set",
              "label": "Question",
              "options": {
                "fields": [
                  {
                    "name": "questionTitle",
                    "label": "Question",
                    "type": "text"
                  },
                  {
                    "name": "questionOrder",
                    "type": "text",
                    "label": "Order",
                    "options": {
                      "type": "number"
                    }
                  },
                  {
                    "name": "questionFieldType",
                    "type": "select",
                    "label": "Html Tag (Answer Field)",
                    "options": {
                      "type": "select",
                      "options": [
                        "Text Area",
                        "Text Field",
                        "Radio Button",
                        "File Upload"
                      ],
                      "default": "Text Area"
                    }
                  }
                ]
              }
            }
          }
        }
      ]
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![raffaelj](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/raffaelj/32/331_2.png) [@raffaelj](https://discourse.getcockpit.com/u/raffaelj)\
**Post date:** [March 23, 2021, 9:48am UTC](https://discourse.getcockpit.com/t/how-to-implement-selectrequestoptions-in-repeater/1883/4 "2021-03-23T09:48:04Z")

</div>

I added code blocks to your post to make the json string readable.

I try to understand your structure…

- repeater
  - set
    - select-request-options
    - repeater
      - set
        - text
        - text
        - select

Is this correct?

---

<div class="post-metadata">

**Author:** ![dhanjiv](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@dhanjiv](https://discourse.getcockpit.com/u/dhanjiv)\
**Post date:** [March 23, 2021, 9:49am UTC](https://discourse.getcockpit.com/t/how-to-implement-selectrequestoptions-in-repeater/1883/5 "2021-03-23T09:49:57Z")

</div>

Yes you are right same i am using

see my json data:  
[{“parentName”:“xcxc”,“categoryName”:“asdas”,“categoryNote”:“sd”,“categoryOrder”:1,“categoryImg”:{“path”:"/admin-cockpit/storage/uploads/2021/01/08/5ff81de8402885f10522c536fb.jpg"}},{“parentName”:“asdsads”,“categoryName”:“asds”,“categoryNote”:“asddsadsa”,“categoryOrder”:2,“categoryImg”:{“path”:"/admin-cockpit/storage/uploads/2020/11/06/5fa4ffda3a7c3CEO-Awards-130\_10934249.jpg"}},{“parentName”:“dsdfsd”,“categoryName”:“test”,“categoryNote”:“xcxzc”,“categoryOrder”:1,“categoryImg”:{“path”:"/admin-cockpit/storage/uploads/2021/01/08/5ff81de8402885f10522c536fb.jpg"}},{“parentName”:“dfdsfsd”,“categoryName”:“dfdsfsd”,“categoryNote”:“dfds”,“categoryOrder”:2,“categoryImg”:null}]

---

<div class="post-metadata">

**Author:** ![raffaelj](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/raffaelj/32/331_2.png) [@raffaelj](https://discourse.getcockpit.com/u/raffaelj)\
**Post date:** [March 23, 2021, 10:15am UTC](https://discourse.getcockpit.com/t/how-to-implement-selectrequestoptions-in-repeater/1883/6 "2021-03-23T10:15:06Z")

</div>

Pleas use fenced code blocks. Otherwise your examples aren’t readable and quotation marks are converted from `"` to `“`. So the code can’t be copied anymore.

````nohighlight
```json
{
  "key": "value"
}
```

````

---

<div class="post-metadata">

**Author:** ![dhanjiv](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@dhanjiv](https://discourse.getcockpit.com/u/dhanjiv)\
**Post date:** [March 23, 2021, 10:18am UTC](https://discourse.getcockpit.com/t/how-to-implement-selectrequestoptions-in-repeater/1883/7 "2021-03-23T10:18:15Z")

</div>

```
[{"parentName":"xcxc","categoryName":"asdas","categoryNote":"sd","categoryOrder":1,"categoryImg":{"path":"\/admin-cockpit\/storage\/uploads\/2021\/01\/08\/5ff81de8402885f10522c536fb.jpg"}},{"parentName":"asdsads","categoryName":"asds","categoryNote":"asddsadsa","categoryOrder":2,"categoryImg":{"path":"\/admin-cockpit\/storage\/uploads\/2020\/11\/06\/5fa4ffda3a7c3CEO-Awards-130_10934249.jpg"}},{"parentName":"dsdfsd","categoryName":"test","categoryNote":"xcxzc","categoryOrder":1,"categoryImg":{"path":"\/admin-cockpit\/storage\/uploads\/2021\/01\/08\/5ff81de8402885f10522c536fb.jpg"}},{"parentName":"dfdsfsd","categoryName":"dfdsfsd","categoryNote":"dfds","categoryOrder":2,"categoryImg":null}]
```

---

<div class="post-metadata">

**Author:** ![raffaelj](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/raffaelj/32/331_2.png) [@raffaelj](https://discourse.getcockpit.com/u/raffaelj)\
**Post date:** [March 23, 2021, 10:34am UTC](https://discourse.getcockpit.com/t/how-to-implement-selectrequestoptions-in-repeater/1883/8 "2021-03-23T10:34:07Z")

</div>

So that json is the output of your repeater field? Or the output of your whole entry?

I don’t want to guess, what your problem is and what you want to achieve. I’m helping here in my spare time, so if you want to get help for free, be so kind to rebuild your setup with a simplified example. Than explain it a bit with copy/pastable code and I’ll have a second look.

---

<div class="post-metadata">

**Author:** ![dhanjiv](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@dhanjiv](https://discourse.getcockpit.com/u/dhanjiv)\
**Post date:** [March 23, 2021, 10:43am UTC](https://discourse.getcockpit.com/t/how-to-implement-selectrequestoptions-in-repeater/1883/9 "2021-03-23T10:43:45Z")

</div>

When i am using without repeater filed data is coming fine

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/getcockpit/original/1X/b213c3c1f888224df8b89bf432e3accdbdea9ab4.png)  
 ![image](https://canada1.discourse-cdn.com/flex030/uploads/getcockpit/original/1X/74516ac3c882b9413f86b237e45b50e663f5bf3c.png)  
but when i am trying to access in repeater that data is not coming, i am using same json for both one

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/getcockpit/original/1X/ad657f1c527835c44d5050df8dba60565db47a6c.png)

i think you will understand now…

---

<div class="post-metadata">

**Author:** ![raffaelj](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/raffaelj/32/331_2.png) [@raffaelj](https://discourse.getcockpit.com/u/raffaelj)\
**Post date:** [March 23, 2021, 5:14pm UTC](https://discourse.getcockpit.com/t/how-to-implement-selectrequestoptions-in-repeater/1883/10 "2021-03-23T17:14:28Z")

</div>

OK, thanks for the screenshots. I think, I understand the problem now.

Does it work if you add a `name` key?

```nohighlight
      "fields": [
        {
          "request": "/category-custom",
          "value": "categoryName",
          "name": "categoryName", // <-- this one
          "label": "categoryName",
          "multiple": false
        },

```

And/or does the repeater with the nested set work without the select-request-option field?

If not, there might be a problem with mounting the field correctly inside the multiple nesting stages. It’s a while ago, that I had a look at that addon, so I’m not sure, what’s going on. I wrote it for a special use case and never used it again…

If I have to reproduce the setup - what does `/category-custom` return? Something like this?

```php
$app->bind('/category-custom', function() {
    return [
        ['categoryName' => 'cat1', 'ignoreThat' => 'do not care'],
        ['categoryName' => 'cat2', 'ignoreThat' => 'not interesting'],
    ];
});

```

Than I’ll have a look at that addon in the next days and try to fix it.

And what’s your cockpit version?

---

<div class="post-metadata">

**Author:** ![raffaelj](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/raffaelj/32/331_2.png) [@raffaelj](https://discourse.getcockpit.com/u/raffaelj)\
**Post date:** [March 23, 2021, 5:23pm UTC](https://discourse.getcockpit.com/t/how-to-implement-selectrequestoptions-in-repeater/1883/11 "2021-03-23T17:23:59Z")

</div>

Now I got it. It’s simple 🙂 It’s not a problem with the [SelectRequestOptions addon](https://github.com/raffaelj/cockpit_SelectRequestOptions) at all. Your field definition inside the set field is wrong.

```nohighlight
      "fields": [
        {
          "name": "categoryName",
          "type": "select-request-options",
          "label": "categoryName",
          "options": {
            "request": "/category-custom",
            "value": "categoryName",
            "label": "categoryName",
            "multiple": false
          },
        },

```

---

<div class="post-metadata">

**Author:** ![dhanjiv](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@dhanjiv](https://discourse.getcockpit.com/u/dhanjiv)\
**Post date:** [March 24, 2021, 5:02am UTC](https://discourse.getcockpit.com/t/how-to-implement-selectrequestoptions-in-repeater/1883/12 "2021-03-24T05:02:58Z")

</div>

Thank you Raffael 😄
