Reputation: 1746
I got a repeated values which are sent from controller. I used it like it in view like this:
<select name="subcategory">
@repeat(data("sub_categories")) { i =>
<option value="@i("id").value">@i("name").value</option>
}
</select>
Now I want to count to get number of items in data("sub_categories")
How can I do that?
I tried data("sub_categories").length
or data("sub_categories").value.length
, both do not work.
Thanks
Upvotes: 0
Views: 87
Reputation: 3294
data
is a Form and data("sub_categories")
is of type Field so for a repeated item you should be able to get number of items by calling data("sub_categories").indexes.length
Upvotes: 1