Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

laravel6's avatar

Remove 'name' field from register form

Is it possible to remove the 'name' field from the register form in Spark? There are instructions to add fields but not remove.

0 likes
3 replies
Cronix's avatar

It's really the same thing as adding fields.

Edit the registration form view, remove the field.

In SparkServiceProvider, override the Spark::validateUsersWith() method and Spark::createUsersWith() method and don't include the field you removed.

Edit: they'd probably just be

        Spark::validateUsersWith(function () {
            return [
               // 'name' => 'required|max:255',
                'email' => 'required|email|max:255|unique:users',
                'password' => 'required|confirmed|min:6',
                'vat_id' => 'max:50|vat_id',
                'terms' => 'required|accepted',
            ];
        });

        Spark::createUsersWith(function (Request $request) {
            $user = Spark::user();
            $data = $request->all();

            $user->forceFill([
                //'name' => $data['name'],
                'email' => $data['email'],
                'password' => bcrypt($data['password']),
                'last_read_announcements_at' => Carbon::now(),
                'trial_ends_at' => Carbon::now()->addDays(Spark::trialDays()),
            ])->save();

            return $user;
        });
laravel6's avatar

As soon as I place this in the booted method of SparkServiceProvider, it throws an error on the front end when registering. Even if I leave the name field and don't change any other code.

"Something went wrong. Please try again or contact customer support."

laravel6's avatar
laravel6
OP
Best Answer
Level 3

Finally solved. After looking through the logs, 'vat_id' was throwing an error. I removed this from validation and it resolved the issue. Thank you for your help.

Steps: Add Spark::validateUsersWith() and Spark::createUsersWith(). Remove 'name' field from view. Make a migration to remove 'name' column in db

Please or to participate in this conversation.