Generate right for attribute for labels in collection inputs

It is wrong if namespace or index option is being used.

Fixes #1161