# fluentform/3.6.50/app/Services/FormBuilder/Components/Name.php

Fluent Forms – Customizable Contact Forms, Survey, Quiz, &amp; Conversational Form Builder, version 3.6.50. 78 lines.

- Page: https://pluginprobe.com/plugins/fluentform/3.6.50/code/app/Services/FormBuilder/Components/Name.php
- Raw: https://pluginprobe.com/plugins/fluentform/3.6.50/raw/app/Services/FormBuilder/Components/Name.php
- Modified: 2020-06-18T18:27:22+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/fluentform/3.6.50/code/app/Services/FormBuilder/Components/Name.php#L10-L20`.

```php
<?php

namespace FluentForm\App\Services\FormBuilder\Components;

use FluentForm\App\Helpers\Helper;
use FluentForm\Framework\Helpers\ArrayHelper;

class Name extends BaseComponent
{
    /**
     * Compile and echo the html element
     * @param  array $data [element data]
     * @param  stdClass $form [Form Object]
     * @return viod
     */
    public function compile($data, $form)
    {
        $elementName = $data['element'];

        $data = apply_filters('fluenform_rendering_field_data_'.$elementName, $data, $form);

        $rootName = $data['attributes']['name'];

        $hasConditions = $this->hasConditions($data) ? 'has-conditions ' : '';
        
        if (empty($data['attributes']['class'])) {
            $data['attributes']['class'] = '';
        }

        $data['attributes']['class'] .= $hasConditions;
        $data['attributes']['class'] .= ' ff-field_container ff-name-field-wrapper';
        if($containerClass = ArrayHelper::get($data, 'settings.container_class')) {
            $data['attributes']['class'] .= ' '.$containerClass;
        }
        $atts = $this->buildAttributes(
            ArrayHelper::except($data['attributes'], 'name')
        );

        $html = "<div {$atts}>";
        $html .= "<div class='ff-t-container'>";

        $labelPlacement = ArrayHelper::get($data, 'settings.label_placement');
        $labelPlacementClass = '';
        
        if ($labelPlacement) {
            $labelPlacementClass = ' ff-el-form-'.$labelPlacement;
        }

        foreach ($data['fields'] as $field) {
            if ($field['settings']['visible']) {
                $fieldName = $field['attributes']['name'];
                $field['attributes']['name'] = $rootName . '[' . $fieldName . ']';
                @$field['attributes']['class'] = trim(
                    'ff-el-form-control ' .
                    $field['attributes']['class']
                );

                if ($tabIndex = \FluentForm\App\Helpers\Helper::getNextTabIndex()) {
                    $field['attributes']['tabindex'] = $tabIndex;
                }


                @$field['settings']['container_class'] .= $labelPlacementClass;

                $field['attributes']['id'] = $this->makeElementId($field, $form);

                $elMarkup = "<input ".$this->buildAttributes($field['attributes']).">";

                $inputTextMarkup = $this->buildElementMarkup($elMarkup, $field, $form);
                $html .= "<div class='ff-t-cell'>{$inputTextMarkup}</div>";
            }
        }
        $html .= "</div>";
        $html .= "</div>";
        echo apply_filters('fluenform_rendering_field_html_'.$elementName, $html, $data, $form);
    }
}

```
