How to implement SelectRequestOptions in repeater?

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

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

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:

{
  "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"
                    }
                  }
                ]
              }
            }
          }
        }
      ]
    }
  }
}

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?

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}]

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.

```json
{
  "key": "value"
}
```
[{"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}]

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.

When i am using without repeater filed data is coming fine



but when i am trying to access in repeater that data is not coming, i am using same json for both one

i think you will understand now…

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

Does it work if you add a name key?

      "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?

$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?

Now I got it. It’s simple :slight_smile: It’s not a problem with the SelectRequestOptions addon at all. Your field definition inside the set field is wrong.

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

Thank you Raffael :smile: