File tree Expand file tree Collapse file tree 2 files changed +50
-8
lines changed
Expand file tree Collapse file tree 2 files changed +50
-8
lines changed Original file line number Diff line number Diff line change @@ -124,14 +124,56 @@ Simple relationship fields with only 1 relationship allowed are very similar in
124124 {/options:my_field_name}
125125 </select>
126126
127- For relationship fields that allow multiple selections, you may also set the sort order:
128-
129- {options:my_field_name}
130- Order:
131- <input type="text" name="my_field_name[sort][]" value="{option_order}" />
132- <input type="checkbox" name="my_field_name[data][]" value="{option_value}" {checked}/>
133- {option_name}<br />
134- {/options:my_field_name}
127+ For relationship fields that allow multiple selections, you may also set the reorderable drag-and-drop lists:
128+
129+ {exp:channel:entries channel="yourChannel"}
130+ <ul id="list-group">
131+ {relationship_field}
132+ <li class="list-item">
133+ <div class="list-item__handle">::</div>
134+ <div class="list-item__content">
135+ <div class="list-item__title">{relationship_field:title}</div>
136+ <div class="list-item__secondary"><span> #{relationship_field:entry_id} / </span>{relationship_field:status}</div>
137+ </div>
138+ </li>
139+ {/relationship_field}
140+ </ul>
141+ {/exp:channel:entries}
142+
143+ You would need a bit of Javascript code (the example below is using SortableJs library):
144+
145+ <script src="https://cdn.jsdelivr.net/npm/sortablejs@latest/Sortable.min.js"></script>
146+ <script>
147+ var el = document.getElementById('list-group');
148+ var sortable = Sortable.create(el);
149+ </script>
150+
151+ Add CSS:
152+
153+ <style>
154+ #list-group {
155+ list-style-type: none;
156+ padding: 0;
157+ margin-left: 15px;
158+ }
159+ #list-group .list-item{
160+ margin-bottom: 10px;
161+ border: 1px solid #cecece;
162+ padding: 5px 15px;
163+ background: #fff;
164+ display: flex;
165+ }
166+ #list-group .list-item__title {
167+ font-weight: bold;
168+ }
169+ #list-group .list-item__handle {
170+ cursor: move;
171+ cursor: -webkit-grabbing;
172+ margin-right: 10px;
173+ }
174+ </style>
175+
176+ ![ Relationship fields] ( _images/sort-relationship.gif )
135177
136178### Select field
137179
You can’t perform that action at this time.
0 commit comments