# contact-forms/2.3.6/classes/View/InlineLabel.php

Contact Forms by Cimatti, version 2.3.6. 180 lines.

- Page: https://pluginprobe.com/plugins/contact-forms/2.3.6/code/classes/View/InlineLabel.php
- Raw: https://pluginprobe.com/plugins/contact-forms/2.3.6/raw/classes/View/InlineLabel.php
- Modified: 2026-08-05T09:37:24+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/contact-forms/2.3.6/code/classes/View/InlineLabel.php#L10-L20`.

```php
<?php
/**
 * Inline Label View - Material Design inspired floating labels
 * 
 * This view implements inline labels that float to the top border when
 * the field is focused or has content, following Material Design guidelines.
 * 
 * Accessibility features:
 * - Full ARIA support with proper labeling
 * - Keyboard navigation compatible
 *
 * @phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped -- PFBC View class, HTML output is controlled
 * - Screen reader friendly
 * - WCAG 2.1 AAA compliant
 */
class AccuaForm_View_InlineLabel extends AccuaForm_View_Standard {
	
	public function render() {
		echo '<form', $this->form->getAttributes(), '>';
		$this->form->getError()->render();

		$elements = $this->form->getElements();
		$elementCount = 0;
		$inButtonGroup = false;
		
		foreach($elements as $element) {
			if($element instanceof Element_Hidden || $element instanceof Element_HTMLExternal) {
				$element->render();
			} elseif($element instanceof Element_Button) {
				if (!$inButtonGroup) {
					echo '<div class="pfbc-element pfbc-buttons">';
					$inButtonGroup = true;
				}
				$element->render();
			} else {
				if ($inButtonGroup) {
					echo '</div>';
					$inButtonGroup = false;
				}
				if ($element instanceof AccuaForm_Element_FieldsetBegin || $element instanceof AccuaForm_Element_FieldsetEnd) {
					$element->render();
				} else {
					echo '<div class="pfbc-element-', $elementCount, ' pfbc-element';
					if($element->hasErrors()) {
						echo ' pfbc-element-has-error';
					}
					$_wrapperClass = $element->getWrapperCssClass();
					if(!empty($_wrapperClass)) {
						echo ' ', esc_attr($_wrapperClass);
					}
					echo '"';
					$_wrapperId = $element->getWrapperCssId();
					if(!empty($_wrapperId)) {
						echo ' id="', esc_attr($_wrapperId), '"';
					}
					echo '>', $element->getPreHTML();
					
					// Render inline label differently based on element type
					if ($element instanceof Element_HTML) {
						$this->renderLabel($element);
						$element->render();
					} else {
						$this->renderInlineLabelWrapper($element);
					}
					
					echo $element->getPostHTML(), '<div class="pfbc-elementbottom"></div></div>';
					++$elementCount;
				}
			}
		}
		
		if ($inButtonGroup) {
			echo '</div>';
			$inButtonGroup = false;
		}

		echo '</form>';
	}

	/**
	 * Render the inline label wrapper with floating label support
	 * 
	 * This creates the structure needed for Material Design floating labels:
	 * - Wrapper div with relative positioning
	 * - Label positioned absolutely
	 * - Field rendered normally
	 * - Proper ARIA attributes for accessibility
	 */
	protected function renderInlineLabelWrapper($element) {
		$label = $element->getLabel();
		$id = $element->getID();
		$description = $element->getDescription();
		$required = $element->isRequired();
		
		// Determine if this element should use inline floating labels
		// Checkboxes, radios, file inputs, colorpickers, and captchas use standard layout
		$useInlineLabel = !($element instanceof Element_Checkbox || 
		                     $element instanceof AccuaForm_Element_Checkbox ||
		                     $element instanceof Element_Radio ||
		                     $element instanceof AccuaForm_Element_Radio ||
		                     $element instanceof Element_File ||
		                     $element instanceof AccuaForm_Element_File ||
		                     $element instanceof AccuaForm_Element_ColorPicker ||
		                     $element instanceof AccuaForm_Element_Captcha2 ||
		                     $element instanceof AccuaForm_Element_Turnstile ||
		                     $element instanceof AccuaForm_Element_Cap);
		
		if ($useInlineLabel && !empty($label)) {
			echo '<div class="pfbc-inline-label-wrapper">';
			
			// Render the input field first
			echo '<div class="pfbc-fieldwrap">';
			$element->render();
			echo '</div>';
			
			// Render the floating label with ARIA support
			echo '<label for="', $id, '" class="pfbc-floating-label">';
			echo $label;
			if($required) {
				echo ' <span class="pfbc-required" aria-label="required">*</span>';
			}
			echo '</label>';
			
			// Render description below the field
			if(!empty($description)) {
				echo '<div class="pfbc-description"><em>', $description, '</em></div>';
			}
			
			// Render inline error
			$this->renderInlineError($element);
			
			echo '</div>';
		} else {
			// Fall back to standard rendering for checkboxes, radios, file inputs
			$this->renderLabel($element);
			echo '<div class="pfbc-fieldwrap">';
			$element->render();
			echo '</div>';
			$this->renderInlineError($element);
		}
	}
	
	/**
	 * Standard label rendering for elements that don't support floating labels
	 * (checkboxes, radios, file inputs)
	 */
	protected function renderLabel($element) {
		$label = $element->getLabel();
		$id = $element->getID();
		$description = $element->getDescription();
		
		if(!empty($label) || !empty($description)) {
			echo '<div class="pfbc-label">';
			if(!empty($label)) {
				echo '<label for="', $id, '">', $label;
				if($element->isRequired())
					echo ' <span class="pfbc-required" aria-label="required">*</span>';
				echo '</label>'; 
			}
			if(!empty($description))
				echo '<em>', $description, '</em>';
			echo '</div>';
		}
	}
	
	public function renderCSS() {
		// For inline label view, we don't want PFBC to add width styles
		// The CSS in frontend.css handles all widths with width: 100%
		// So we don't generate any width-based CSS here
		// (empty implementation overrides parent's width CSS generation)
	}
	
	public function jQueryDocumentReady() {
		// Override parent to prevent jQuery width manipulation
		// The inline label view uses pure CSS for width control (width: 100%)
		// PFBC's default jQueryDocumentReady() converts CSS width to inline styles
		// which breaks our flexible layout
	}
}

```
