public function validateSegment($element, FormStateInterface $formState)
    {
        $originalValue = trim($formState->getValue('segment'));

        if (!empty($originalValue)) {

            $value = $this->seoService->normalizeSegment($originalValue);

            if ($originalValue !== $value) {
                $formState->setError(
                    $element,
                    $this->t(
                        "The alias '%alias' is invalid and has been normalized to: <strong>%normalized</strong>, please change the value below.",
                        ['%alias' => $originalValue, '%normalized' => $value]
                    )
                );
            }

            $formState->setValueForElement($element, $value);
        }
    }
public function validateSegment($element, FormStateInterface $formState)
    {
        $originalValue = trim($formState->getValue('segment'));

        if (!empty($originalValue)) {

            $value = $this->seoService->normalizeSegment($originalValue);

            if ($originalValue !== $value) {
                $formState->setError(
                    $element,
                    $this->t(
                        "The alias '%alias' is invalid and has been normalized to: <strong>%normalized</strong>, please change the value below.",
                        ['%alias' => $originalValue, '%normalized' => $value]
                    )
                );
            }

            $formState->setValueForElement($element, $value);
        }
    }
public function validateSegment ( $ element , FormStateInterface $ formState ) { $ originalValue = trim ( $ formState -> getValue ( 'segment' ) ) ; if ( ! empty ( $ originalValue ) ) { $ value = $ this -> seoService -> normalizeSegment ( $ originalValue ) ; if ( $ originalValue !== $ value ) { $ formState -> setError ( $ element , $ this -> t ( "The alias '%alias' is invalid and has been normalized to: <strong>%normalized</strong>, please change the value below." , [ '%alias' => $ originalValue , '%normalized' => $ value ] ) ) ; } $ formState -> setValueForElement ( $ element , $ value ) ; } }
Validate the alias segment field
Validate the alias segment field