Skip to content

TypeError: Argument #1 ($handle) Must Be String in Statamic Forms Import Command #389

Closed
@emran-alhaddad

Description

@emran-alhaddad

Bug description

What happened?
Running the command php please eloquent:import-forms and selecting to import form submissions results in a TypeError. The error message indicates that Statamic\Fields\Blueprint::setHandle() expects a string, but null was given.

What did you expect to happen?
The forms and their submissions should be imported successfully without errors.

Error Output:

TypeError 

Statamic\Fields\Blueprint::setHandle(): Argument #1 ($handle) must be of type string, null given, called in vendor/statamic/cms/src/Forms/Form.php on line 80

at vendor/statamic/cms/src/Fields/Blueprint.php:50
     46▕     private $lastBlueprintHandle = null;
     47▕ 
     48▕     private ?Columns $columns = null;
     49▕ 
  ➜  50▕     public function setHandle(string $handle)
     51▕     {
     52▕         $this->handle = $handle;
     53▕ 
     54▕         return $this;

      +15 vendor frames 

  16  [internal]:0
      Statamic\Stache\Stores\Store::Statamic\Stache\Stores\{closure}()
      +4 vendor frames 

  21  [internal]:0
      Statamic\Stache\Query\SubmissionQueryBuilder::Statamic\Stache\Query\{closure}()

How to reproduce

  1. Navigate to the project directory.

  2. Run the following command: php please eloquent:import-forms

When prompted:

Do you want to import forms? (yes/no) [no]:
> yes

Do you want to import form submissions? (yes/no) [no]:
> yes
  1. Observe the TypeError regarding Blueprint::setHandle().

Logs

No response

Environment

Environment
Application Name: ****
Laravel Version: 11.34.2
PHP Version: 8.2.22
Composer Version: 2.5.5
Environment: production
Debug Mode: ENABLED
URL: ***
Maintenance Mode: OFF
Timezone: UTC
Locale: en

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: file
Database: mysql
Logs: stack / single
Mail: smtp
Queue: sync
Session: file

Statamic
Addons: 3
Sites: 2 (Arabic, English)
Stache Watcher: Enabled
Static Caching: Disabled
Version: 5.42.0 PRO

Statamic Addons
isaadsalman/headless-refresh: 1.0.0
ndx/statamic-bard-color-picker: 2.0.0
statamic/eloquent-driver: 4.19.0

Statamic Eloquent Driver
Asset Containers: eloquent
Assets: eloquent
Blueprints: eloquent
Collection Trees: eloquent
Collections: eloquent
Entries: eloquent
Forms: eloquent
Global Sets: eloquent
Global Variables: eloquent
Navigation Trees: eloquent
Navigations: eloquent
Revisions: file
Sites: eloquent
Taxonomies: eloquent
Terms: eloquent
Tokens: eloquent

Additional details

this is one of the samples of forms submissions that give the issue
form blueprint:

tabs:
  main:
    display: Main
    sections:
      -
        fields:
          -
            handle: subject
            field:
              type: text
              display: Subject
              validate:
                - required
          -
            handle: first_name
            field:
              type: text
              display: 'First Name'
              width: 50
          -
            handle: last_name
            field:
              type: text
              display: 'Last Name'
              width: 50
          -
            handle: gender
            field:
              options:
                male: 'Male / ذكر'
                female: 'Female / انثى'
              type: select
              display: Gender
          -
            handle: email
            field:
              input_type: email
              type: text
              display: Email
          -
            handle: company_name
            field:
              type: text
              display: 'Company Name'
          -
            handle: job_title
            field:
              type: text
              display: 'Job Title'
          -
            handle: phone
            field:
              type: text
              display: Phone

form submission:

subject: Test
first_name: test
last_name: test
gender: Male
email: [email protected]
company_name: 'test'
job_title: 'test'
phone: '0555555555'

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions