[html-formfu] Different attributes for the first record in a
repeatable block
Ascii King
tech at swattermatter.com
Wed Apr 1 13:45:31 BST 2009
That's great, thanks. That's almost exactly what I had except I had put
brackets on the end of the get_elements, so I couldn't get it to work.
Carl Franks wrote:
> 2009/3/31 Ascii King <tech at swattermatter.com>:
>
>> That works great! Thank you. How do I count the number of elements returned
>> by the get_all_element function?
>>
>> $form->get_all_element({ type => Repeatable })
>>
>> If I display the variable, I can see that I get four elements, but I don't
>> know how to count them with code.
>>
>
> "get_all_element" will only return the 1st item that would otherwise
> be returned by "get_all_elements".
> The "all" just means it works recursively.
>
> So in your case, "get_all_element" should be returning a Block, which
> itself contains some number of elements.
>
> It's not very pretty - you have to dereference the array-ref to a
> list, then count it in scalar context:
>
> $count = scalar @{ $form->get_all_elements({ type =>
> Repeatable})->get_elements };
>
> Hope that helps,
> Carl
>
> _______________________________________________
> HTML-FormFu mailing list
> HTML-FormFu at lists.scsys.co.uk
> http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu
>
>
More information about the HTML-FormFu
mailing list