Support the ongoing development of Laravel.io →
posted 9 years ago
Requests

I've got a select list in a form

    <div class="form-group {!! $errors->has('primenom') ? 'has-error' : '' !!}">
                                {!! Form::label('user_id', 'Selectionner l\'utilisateur : ', ['class' => 'control-label']) !!}
                                {!! Form::select('user_id', array_merge(['0' => 'Selectionnez l\' utilisateur'], $usersList->ToArray() ), 'Selectionnez l\' utilisateur', ['class' => 'form-control']) !!}
                            {!! $errors->first('user_id', '<small class="help-block">:message</small>') !!}
                        </div>

I've builded a specific request class with these rules :

public function rules()
    {
        return [
            'user_id' => 'regex:[?/! ^(Selectionner l\'utilisateur)]',
            'primenom' => 'required|numeric',
            'primevalue' => 'required|numeric',
        ];
    }

I've tried to test if the end user has change the default value "selectionner votre utilisateur" with a real value which is content in the $usersList->toArray();

I try with a regex exclusion, but I think I'm a regex loser ;)

PS: I'm french so excuse me for my english ;)

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

jay4yam jay4yam Joined 29 Jun 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.