TAP5-2643: NPE in Label when corresponding form field isn't rendered
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Label.java b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Label.java
index bc3fa8d..dd153b3 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Label.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Label.java
@@ -118,9 +118,13 @@
         labelElement.attribute("id", id);
         labelElement.forceAttributes("for", fieldId);
         
-        Element input = labelElement.getDocument().getElementById(field.getClientId());
-        if (input != null) {
-            input.attribute("aria-labelledby", id);
+        if (fieldId != null)
+        {
+            Element input = labelElement.getDocument().getElementById(field.getClientId());
+            if (input != null) 
+            {
+                input.attribute("aria-labelledby", id);
+            }
         }
         
         decorator.insideLabel(field, labelElement);