Skip to content

File component calls undefined format_file_size() when rendering its hint #19

Closed

Description

@n4ff4h

<x-forms::file> (and the components extending File) crash when they render their default hint, unless the app happens to define a global format_file_size():

Error: Call to undefined function Javaabu\Forms\Views\Components\format_file_size()
  at src/Views/Components/File.php:117 (File::getHint())

format_file_size() isn't defined by javaabu/forms or by javaabu/helpers ^1.74 (only by apps that copied it from the old skeleton). Reproduce in a plain Testbench app:

<x-forms::file name="file" :label="__('File')" :extensions="['csv', 'xlsx']" :max-size="51200" />

Needed: format the size inside the package (e.g. Illuminate\Support\Number::fileSize($this->maxSize * 1024), max size being in KB), or ship the helper. A test rendering <x-forms::file> with its hint would catch it.

Found by: javaabu/imports v2 (n4ff4h/imports, next-gen) uses <x-forms::file> for the upload form. Until this is fixed it passes its own help text, which skips getHint(). That's an ordinary attribute, not a workaround, but the default hint can't be used.

Activity

  1. added
    next-genNext-gen Javaabu packages
    cross-packageRequested by or affecting another next-gen package
    on Nov 4, 2026
  2. added a commit that references this issue on Nov 4, 2026
    3cf84cd
  3. n4ff4h commented on Nov 4, 2026

    @n4ff4h
    Author

    Fixed on next-gen by the #18 work (cdc4bae), with a regression test in 3cf84cd; CI green. File::getHint() now uses the package's own Javaabu\Forms\Support\MimeTypes::formatFileSize(), with the KB/MB/GB units from forms::strings. Nothing calls a global format_file_size() any more. The test renders your example (:extensions="['csv', 'xlsx']" :max-size="51200") and checks that the hint reads "Only .csv and .xlsx files of max 50MB allowed.", plus the Dhivehi hint. imports can drop its custom help text.

  4. n4ff4h commented on Nov 4, 2026

    @n4ff4h
    Author

    Fixed on next-gen by the #18 work (cdc4bae), with a regression test in 3cf84cd; CI green. File::getHint() now uses the package's own Javaabu\Forms\Support\MimeTypes::formatFileSize(), with the KB/MB/GB units from forms::strings. Nothing calls a global format_file_size() any more. The test renders your example (:extensions="['csv', 'xlsx']" :max-size="51200") and checks that the hint reads "Only .csv and .xlsx files of max 50MB allowed.", plus the Dhivehi hint. imports can drop its custom help text.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    cross-packageRequested by or affecting another next-gen packagenext-genNext-gen Javaabu packages

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions