Reputation: 395
I get a error JSON in following format
error = [{field:'one', desc:'This is error for field one', value='FromPostFieldOne'},
{field:'two', desc:'This is error for field two', value='FromPostFieldTwo'}];
which I want to display in following template
{#error}
<form>
<input type="text" name="one" id="one" value="<!- value for field one from JSON-->"/>
<!-- Display error from JSON for field one here -->
<input type="text" name="two" id="two" value="<!- value for field two from JSON -->"/>
<!-- Display error from JSON for field two here -->
</form>
{/error}
I am not able to figure if I achieve this with ether "Explicit context setting" or "{@if cond="condition"} helper". All examples on Linkedin Dust site illustrate how to do this with JSON key values but not object arrays.
Help appreciated !!!!
Upvotes: 0
Views: 249
Reputation: 5999
your json is not valid you should make something like this:
error = [
{
field:'one',
desc:'This is error for field one',
value:'FromPostFieldOne'
},
{
field:'two',
desc:'This is error for field two',
value:'FromPostFieldTwo'}
];
Upvotes: 1