z-song/laravel-admin · error · InvalidArgumentException

The second paramater `$on` must be one of ['create', 'edit']

Error message

The second paramater `$on` must be one of ['create', 'edit']

What it means

Error "The second paramater `$on` must be one of ['create', 'edit']" thrown in z-song/laravel-admin.

Source

Thrown at src/Form.php:1271

    public function setTitle($title = ''): self
    {
        $this->builder()->setTitle($title);

        return $this;
    }

    /**
     * Set a submit confirm.
     *
     * @param string $message
     * @param string $on
     *
     * @return $this
     */
    public function confirm(string $message, $on = null)
    {
        if ($on && !in_array($on, ['create', 'edit'])) {
            throw new \InvalidArgumentException("The second paramater `\$on` must be one of ['create', 'edit']");
        }

        if ($on == 'create' && !$this->isCreating()) {
            return;
        }

        if ($on == 'edit' && !$this->isEditing()) {
            return;
        }

        $this->builder()->confirm($message);

        return $this;
    }

    /**
     * Add a row in form.
     *

View on GitHub (pinned to 67c441eb78)

When it happens

Trigger: Thrown at src/Form.php:1271 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of z-song/laravel-admin@67c441eb78 (2026-08-21). Data as JSON: /api/errors/f54e5023a9814763. Report an issue: GitHub.