Remove 'name' field from register form

Published 5 days ago by laravel6

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

Best Answer (As Selected By laravel6)
laravel6

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

Cronix
Cronix
5 days ago (727,800 XP)

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

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

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 sign in or create an account to participate in this conversation.