|
2 | 2 |
|
3 | 3 | <Badge type="tip" vertical="top" text="Elementor Core" /> <Badge type="warning" vertical="top" text="Advanced" /> |
4 | 4 |
|
5 | | -WIP |
| 5 | +Some Elementor widgets and elements use the [repeater control](./../editor-controls/control-repeater/) to allow users to add repeatable blocks of fields. The repeater data is saved inside the element's `settings` object as an `array` of objects, where each object represents a single repeater item with its inner field values. |
| 6 | + |
| 7 | +## JSON Structure |
| 8 | + |
| 9 | +A repeater value is saved as an array of objects. Each item is an object of key-value pairs representing the inner field values. Elementor automatically adds a unique `_id` to every item: |
| 10 | + |
| 11 | +```json |
| 12 | +{ |
| 13 | + "settings": { |
| 14 | + "repeater_control_name": [ |
| 15 | + { |
| 16 | + "_id": "abcd1234", |
| 17 | + "field_name": "field value", |
| 18 | + "field_name": "field value" |
| 19 | + }, |
| 20 | + { |
| 21 | + "_id": "efgh5678", |
| 22 | + "field_name": "field value", |
| 23 | + "field_name": "field value" |
| 24 | + } |
| 25 | + ] |
| 26 | + } |
| 27 | +} |
| 28 | +``` |
| 29 | + |
| 30 | +## JSON Values |
| 31 | + |
| 32 | +Each repeater item contains the following: |
| 33 | + |
| 34 | +| Argument | Type | Description | |
| 35 | +|---------------|------------|-------------| |
| 36 | +| `_id` | _`string`_ | A unique identifier automatically generated for the repeater item. Used as a CSS selector reference (`elementor-repeater-item-{{_id}}`) and to track the item when editing. | |
| 37 | +| _field name_ | _`mixed`_ | One key per inner field defined in the repeater control. The value type depends on the inner control type (string, object, array, etc.). | |
| 38 | + |
| 39 | +## Examples |
| 40 | + |
| 41 | +### Simple Repeater |
| 42 | + |
| 43 | +A widget with a repeater that holds a list of items, where each item has a title and a text content: |
| 44 | + |
| 45 | +```json |
| 46 | +{ |
| 47 | + "id": "6a637978", |
| 48 | + "elType": "widget", |
| 49 | + "widgetType": "test-widget", |
| 50 | + "isInner": false, |
| 51 | + "settings": { |
| 52 | + "list": [ |
| 53 | + { |
| 54 | + "_id": "a1b2c3d", |
| 55 | + "list_title": "Title #1", |
| 56 | + "list_content": "Item content. Click the edit button to change this text." |
| 57 | + }, |
| 58 | + { |
| 59 | + "_id": "e4f5g6h", |
| 60 | + "list_title": "Title #2", |
| 61 | + "list_content": "Item content. Click the edit button to change this text." |
| 62 | + } |
| 63 | + ] |
| 64 | + }, |
| 65 | + "elements": [] |
| 66 | +} |
| 67 | +``` |
| 68 | + |
| 69 | +### Repeater with Mixed Field Types |
| 70 | + |
| 71 | +A repeater where each item contains a text field, a URL field and a color field: |
| 72 | + |
| 73 | +```json |
| 74 | +{ |
| 75 | + "id": "687dba89", |
| 76 | + "elType": "widget", |
| 77 | + "widgetType": "test-widget", |
| 78 | + "isInner": false, |
| 79 | + "settings": { |
| 80 | + "list": [ |
| 81 | + { |
| 82 | + "_id": "1a2b3c4", |
| 83 | + "text": "List Item #1", |
| 84 | + "link": { |
| 85 | + "url": "https://elementor.com/", |
| 86 | + "is_external": "", |
| 87 | + "nofollow": "" |
| 88 | + }, |
| 89 | + "item_color": "#FF0000" |
| 90 | + }, |
| 91 | + { |
| 92 | + "_id": "5d6e7f8", |
| 93 | + "text": "List Item #2", |
| 94 | + "link": { |
| 95 | + "url": "https://elementor.com/contact/", |
| 96 | + "is_external": "on", |
| 97 | + "nofollow": "" |
| 98 | + }, |
| 99 | + "item_color": "#00FF00" |
| 100 | + } |
| 101 | + ] |
| 102 | + }, |
| 103 | + "elements": [] |
| 104 | +} |
| 105 | +``` |
| 106 | + |
| 107 | +### Repeater with Responsive Fields |
| 108 | + |
| 109 | +Repeater items can also hold [responsive values](./responsive-data/) when the inner controls are responsive. Each device suffix is added directly to the inner field name: |
| 110 | + |
| 111 | +```json |
| 112 | +{ |
| 113 | + "id": "6f58bb5", |
| 114 | + "elType": "widget", |
| 115 | + "widgetType": "test-widget", |
| 116 | + "isInner": false, |
| 117 | + "settings": { |
| 118 | + "slides": [ |
| 119 | + { |
| 120 | + "_id": "x1y2z3a", |
| 121 | + "slide_title": "First Slide", |
| 122 | + "slide_align": "start", |
| 123 | + "slide_align_tablet": "center", |
| 124 | + "slide_align_mobile": "center" |
| 125 | + }, |
| 126 | + { |
| 127 | + "_id": "b4c5d6e", |
| 128 | + "slide_title": "Second Slide", |
| 129 | + "slide_align": "end", |
| 130 | + "slide_align_tablet": "center", |
| 131 | + "slide_align_mobile": "start" |
| 132 | + } |
| 133 | + ] |
| 134 | + }, |
| 135 | + "elements": [] |
| 136 | +} |
| 137 | +``` |
0 commit comments