FOF30\Form\Header\HeaderBase::getId PHP Method

getId() protected method

Method to get the id used for the field input tag.
Since: 2.0
protected getId ( string $fieldId, string $fieldName ) : string
$fieldId string The field element id.
$fieldName string The field element name.
return string The id to be used for the field input tag.
    protected function getId($fieldId, $fieldName)
    {
        $id = '';
        // If the field is in a group add the group control to the field id.
        if ($this->group) {
            // If we already have an id segment add the group control as another level.
            if ($id) {
                $id .= '_' . str_replace('.', '_', $this->group);
            } else {
                $id .= str_replace('.', '_', $this->group);
            }
        }
        // If we already have an id segment add the field id/name as another level.
        if ($id) {
            $id .= '_' . ($fieldId ? $fieldId : $fieldName);
        } else {
            $id .= $fieldId ? $fieldId : $fieldName;
        }
        // Clean up any invalid characters.
        $id = preg_replace('#\\W#', '_', $id);
        return $id;
    }