diff --git a/Form/FieldTypeHandler/TextLine.php b/Form/FieldTypeHandler/TextLine.php index 9105554..209400a 100644 --- a/Form/FieldTypeHandler/TextLine.php +++ b/Form/FieldTypeHandler/TextLine.php @@ -38,23 +38,27 @@ protected function buildFieldForm( { $options = $this->getDefaultFieldOptions( $fieldDefinition, $languageCode, $content ); - $minStringLength = $fieldDefinition->validatorConfiguration["StringLengthValidator"]["minStringLength"]; - $maxStringLength = $fieldDefinition->validatorConfiguration["StringLengthValidator"]["maxStringLength"]; - $lengthConstraints = array(); - - if ( $minStringLength !== false ) + if ( !empty( $fieldDefinition->validatorConfiguration["StringLengthValidator"] ) ) { - $lengthConstraints["min"] = $minStringLength; - } + $lengthConstraints = array(); - if ( $maxStringLength !== false ) - { - $lengthConstraints["max"] = $maxStringLength; - } + $minStringLength = $fieldDefinition->validatorConfiguration["StringLengthValidator"]["minStringLength"]; + $maxStringLength = $fieldDefinition->validatorConfiguration["StringLengthValidator"]["maxStringLength"]; - if ( !empty( $lengthConstraints ) ) - { - $options["constraints"][] = new Constraints\Length( $lengthConstraints ); + if ( $minStringLength !== false ) + { + $lengthConstraints["min"] = $minStringLength; + } + + if ( $maxStringLength !== false ) + { + $lengthConstraints["max"] = $maxStringLength; + } + + if ( !empty( $lengthConstraints ) ) + { + $options["constraints"][] = new Constraints\Length( $lengthConstraints ); + } } $formBuilder->add( $fieldDefinition->identifier, "text", $options );