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

ChrisBarrett's avatar

Adding Team Registration Field

I am struggling to add a new field to the teams table as part of sign up.

I have set up the form to collect the Teams country:

Country:
    <select name="country" class="form-control" v-model="registerForm.country"
           :class="{'is-invalid': registerForm.errors.has('country')}">
      <option value="">Please Select ...</option>
      <option value="1">Fiji</option>
      <option value="2">Samoa</option>
    </select >

    <span class="invalid-feedback" v-show="registerForm.errors.has('country')">
            @{{ registerForm.errors.get('country') }}
    </span>
    </div>
</div>

I have added validation to the SparkServiceProvider file that works fine:

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

I have also added the following SparkServiceProvider to store the form data:

Spark::swap('TeamRepository@create', function ($user, array $data) { $attributes = [ 'owner_id' => $user->id, 'name' => $data['name'], 'team_country_id' => $data['country'], 'trial_ends_at' => Carbon::now()->addDays(Spark::teamTrialDays()), ];

        if (Spark::teamsIdentifiedByPath()) {
            $attributes['slug'] = $data['slug'];
        }
        
        return Spark::team()->forceCreate($attributes);
    });

This works fine if I comment out the 'team_country_id' field (or hard code to a specific value), however if I try to get the team_country_id value from the registration form it gives the following error:

local.ERROR: Undefined index: country

Can anyone point me in the right direction for this - help greatly appreciated.

0 likes
0 replies

Please or to participate in this conversation.