Cyb3r
Well-known member
I have followed this tutorial and it's working fine but I don't know how to add more fields to that option dynamically, here's my template:
And this is the option array:
When clicking save I get this big error:
Though the fields shows and everything but when I add text to them and save I get this error:
Any ideas?
Thanks in advance.
HTML:
<xen:controlunit label="{$preparedOption.title}">
<ul class="FieldChoices">
<xen:foreach loop="$preparedOption.option_value" key="$choice" value="$badge">
<xen:if is="{$badge}">
<li>
<input type="text" name="{$fieldPrefix}[{$preparedOption.option_id}][$choice][id]" value="{$badge.id}" class="textCtrl" placeholder="Badge Unique Identifier" size="15" />
<input type="text" name="{$fieldPrefix}[{$preparedOption.option_id}][$choice][title]" value="{$badge.title}" class="textCtrl" placeholder="Badge Title" size="15" />
<input type="text" name="{$fieldPrefix}[{$preparedOption.option_id}][$choice][img]" value="{$badge.img}" class="textCtrl" placeholder="Icon Path" size="15" />
<input type="text" name="{$fieldPrefix}[{$preparedOption.option_id}][$choice][user]" value="{$badge.user}" class="textCtrl" placeholder="UserId" size="15" />
<input type="text" name="{$fieldPrefix}[{$preparedOption.option_id}][$choice][group]" value="{$badge.group}" class="textCtrl" placeholder="Or GroupId" size="15" />
</li>
<xen:set var="$cur_key">{$choice}</xen:set>
</xen:if>
</xen:foreach>
<li>
<input type="text" name="{$fieldPrefix}[{$preparedOption.option_id}][{xen:calc '{$cur_key} + 1'}][id]" value="{$badge.id}" class="textCtrl" placeholder="Badge Unique Identifier" size="15" />
<input type="text" name="{$fieldPrefix}[{$preparedOption.option_id}][{xen:calc '{$cur_key} + 1'}][title]" value="{$badge.title}" class="textCtrl" placeholder="Badge Title" size="15" />
<input type="text" name="{$fieldPrefix}[{$preparedOption.option_id}][{xen:calc '{$cur_key} + 1'}][img]" value="{$badge.img}" class="textCtrl" placeholder="Icon Path" size="15" />
<input type="text" name="{$fieldPrefix}[{$preparedOption.option_id}][{xen:calc '{$cur_key} + 1'}][user]" value="{$badge.user}" class="textCtrl" placeholder="UserId" size="15" />
<input type="text" name="{$fieldPrefix}[{$preparedOption.option_id}][{xen:calc '{$cur_key} + 1'}][group]" value="{$badge.group}" class="textCtrl" placeholder="Or GroupId" size="15" />
</li>
</ul>
<input type="button" value="{xen:phrase add_additional_choice}" class="button smallButton FieldAdder" data-source="ul.FieldChoices li" />
<p class="explain">{xen:raw $preparedOption.explain}</p>
{xen:raw $editLink}
</xen:controlunit>
<script>
$(document).ready(function() {
$('#{$preparedOption.title}Adder').click(function() {
$('#{$preparedOption.title}Container').children().last().children().each(function() {
$(this).attr('name',$(this).attr('name').replace( /(\d+)/, function(){return arguments[1]*1+1}));
});
});
});
</script>
And this is the option array:
Code:
Edit Format: Named Template
Format Parameters: my_template
Data Type: Array
Default Value: a:5:{s:2:"id";s:5:"none";s:5:"title";s:5:"none";s:3:"img";s:5:"none";s:4:"user";s:5:"none";s:5:"group";s:5:"none";}
Array Sub-Options:
id
title
img
user
group
When clicking save I get this big error:
Code:
Illegal string offset 'id' in C:\xampp\htdocs\rg\library\XenForo\Template\Abstract.php(265) : eval()'d code, line 31:
30: <li>
31: <input type="text" name="' . htmlspecialchars($fieldPrefix, ENT_QUOTES, 'UTF-8') . '[' . htmlspecialchars($preparedOption['option_id'], ENT_QUOTES, 'UTF-8') . '][' . ($cur_key + 1) . '][id]" value="' . htmlspecialchars($badge['id'], ENT_QUOTES, 'UTF-8') . '" class="textCtrl" placeholder="Badge Unique Identifier" size="15" />
32: <input type="text" name="' . htmlspecialchars($fieldPrefix, ENT_QUOTES, 'UTF-8') . '[' . htmlspecialchars($preparedOption['option_id'], ENT_QUOTES, 'UTF-8') . '][' . ($cur_key + 1) . '][title]" value="' . htmlspecialchars($badge['title'], ENT_QUOTES, 'UTF-8') . '" class="textCtrl" placeholder="Badge Title" size="15" />
Illegal string offset 'title' in C:\xampp\htdocs\rg\library\XenForo\Template\Abstract.php(265) : eval()'d code, line 32:
31: <input type="text" name="' . htmlspecialchars($fieldPrefix, ENT_QUOTES, 'UTF-8') . '[' . htmlspecialchars($preparedOption['option_id'], ENT_QUOTES, 'UTF-8') . '][' . ($cur_key + 1) . '][id]" value="' . htmlspecialchars($badge['id'], ENT_QUOTES, 'UTF-8') . '" class="textCtrl" placeholder="Badge Unique Identifier" size="15" />
32: <input type="text" name="' . htmlspecialchars($fieldPrefix, ENT_QUOTES, 'UTF-8') . '[' . htmlspecialchars($preparedOption['option_id'], ENT_QUOTES, 'UTF-8') . '][' . ($cur_key + 1) . '][title]" value="' . htmlspecialchars($badge['title'], ENT_QUOTES, 'UTF-8') . '" class="textCtrl" placeholder="Badge Title" size="15" />
33: <input type="text" name="' . htmlspecialchars($fieldPrefix, ENT_QUOTES, 'UTF-8') . '[' . htmlspecialchars($preparedOption['option_id'], ENT_QUOTES, 'UTF-8') . '][' . ($cur_key + 1) . '][img]" value="' . htmlspecialchars($badge['img'], ENT_QUOTES, 'UTF-8') . '" class="textCtrl" placeholder="Icon Path" size="15" />
Illegal string offset 'img' in C:\xampp\htdocs\rg\library\XenForo\Template\Abstract.php(265) : eval()'d code, line 33:
32: <input type="text" name="' . htmlspecialchars($fieldPrefix, ENT_QUOTES, 'UTF-8') . '[' . htmlspecialchars($preparedOption['option_id'], ENT_QUOTES, 'UTF-8') . '][' . ($cur_key + 1) . '][title]" value="' . htmlspecialchars($badge['title'], ENT_QUOTES, 'UTF-8') . '" class="textCtrl" placeholder="Badge Title" size="15" />
33: <input type="text" name="' . htmlspecialchars($fieldPrefix, ENT_QUOTES, 'UTF-8') . '[' . htmlspecialchars($preparedOption['option_id'], ENT_QUOTES, 'UTF-8') . '][' . ($cur_key + 1) . '][img]" value="' . htmlspecialchars($badge['img'], ENT_QUOTES, 'UTF-8') . '" class="textCtrl" placeholder="Icon Path" size="15" />
34: <input type="text" name="' . htmlspecialchars($fieldPrefix, ENT_QUOTES, 'UTF-8') . '[' . htmlspecialchars($preparedOption['option_id'], ENT_QUOTES, 'UTF-8') . '][' . ($cur_key + 1) . '][user]" value="' . htmlspecialchars($badge['user'], ENT_QUOTES, 'UTF-8') . '" class="textCtrl" placeholder="UserId" size="15" />
Illegal string offset 'user' in C:\xampp\htdocs\rg\library\XenForo\Template\Abstract.php(265) : eval()'d code, line 34:
33: <input type="text" name="' . htmlspecialchars($fieldPrefix, ENT_QUOTES, 'UTF-8') . '[' . htmlspecialchars($preparedOption['option_id'], ENT_QUOTES, 'UTF-8') . '][' . ($cur_key + 1) . '][img]" value="' . htmlspecialchars($badge['img'], ENT_QUOTES, 'UTF-8') . '" class="textCtrl" placeholder="Icon Path" size="15" />
34: <input type="text" name="' . htmlspecialchars($fieldPrefix, ENT_QUOTES, 'UTF-8') . '[' . htmlspecialchars($preparedOption['option_id'], ENT_QUOTES, 'UTF-8') . '][' . ($cur_key + 1) . '][user]" value="' . htmlspecialchars($badge['user'], ENT_QUOTES, 'UTF-8') . '" class="textCtrl" placeholder="UserId" size="15" />
35: <input type="text" name="' . htmlspecialchars($fieldPrefix, ENT_QUOTES, 'UTF-8') . '[' . htmlspecialchars($preparedOption['option_id'], ENT_QUOTES, 'UTF-8') . '][' . ($cur_key + 1) . '][group]" value="' . htmlspecialchars($badge['group'], ENT_QUOTES, 'UTF-8') . '" class="textCtrl" placeholder="Or GroupId" size="15" />
Illegal string offset 'group' in C:\xampp\htdocs\rg\library\XenForo\Template\Abstract.php(265) : eval()'d code, line 35:
34: <input type="text" name="' . htmlspecialchars($fieldPrefix, ENT_QUOTES, 'UTF-8') . '[' . htmlspecialchars($preparedOption['option_id'], ENT_QUOTES, 'UTF-8') . '][' . ($cur_key + 1) . '][user]" value="' . htmlspecialchars($badge['user'], ENT_QUOTES, 'UTF-8') . '" class="textCtrl" placeholder="UserId" size="15" />
35: <input type="text" name="' . htmlspecialchars($fieldPrefix, ENT_QUOTES, 'UTF-8') . '[' . htmlspecialchars($preparedOption['option_id'], ENT_QUOTES, 'UTF-8') . '][' . ($cur_key + 1) . '][group]" value="' . htmlspecialchars($badge['group'], ENT_QUOTES, 'UTF-8') . '" class="textCtrl" placeholder="Or GroupId" size="15" />
36: </li>
Though the fields shows and everything but when I add text to them and save I get this error:
Code:
The following sub-option(s) are unknown: 1.
Any ideas?
Thanks in advance.