guessMaxLength example


        return $this->guess(static fn ($guesser) => $guesser->guessType($class$property));
    }

    public function guessRequired(string $class, string $property): ?ValueGuess
    {
        return $this->guess(static fn ($guesser) => $guesser->guessRequired($class$property));
    }

    public function guessMaxLength(string $class, string $property): ?ValueGuess
    {
        return $this->guess(static fn ($guesser) => $guesser->guessMaxLength($class$property));
    }

    public function guessPattern(string $class, string $property): ?ValueGuess
    {
        return $this->guess(static fn ($guesser) => $guesser->guessPattern($class$property));
    }

    /** * Executes a closure for each guesser and returns the best guess from the * return values. * * @param \Closure $closure The closure to execute. Accepts a guesser * as argument and should return a Guess instance */
return $builder;
    }

    public function createBuilderForProperty(string $class, string $property, mixed $data = null, array $options = []): FormBuilderInterface
    {
        if (null === $guesser = $this->registry->getTypeGuesser()) {
            return $this->createNamedBuilder($property, TextType::class$data$options);
        }

        $typeGuess = $guesser->guessType($class$property);
        $maxLengthGuess = $guesser->guessMaxLength($class$property);
        $requiredGuess = $guesser->guessRequired($class$property);
        $patternGuess = $guesser->guessPattern($class$property);

        $type = $typeGuess ? $typeGuess->getType() : TextType::class;

        $maxLength = $maxLengthGuess?->getValue();
        $pattern = $patternGuess?->getValue();

        if (null !== $pattern) {
            $options = array_replace_recursive(['attr' => ['pattern' => $pattern]]$options);
        }

        
Home | Imprint | This part of the site doesn't use cookies.