As discussed in chat, you will be using the same form both on the registration page and on the editing page. On the registration page, you want the third parameter of Form::select be it null, because the user has not yet selected some value. Already on the editing page, you want this third parameter to be the value of $coupon->cupUnic, which is the value stored in the database. Whereas you are using PHP 7, as also said in chat, you can use the null coalescence operator to return the value of the variable, if it is set, or null otherwise.
$coupon->cupUnic ?? null
In your case, the Form::select would be:
{!! Form::select('cupUnic', ['' => 'Selecione', '1' => 'Sim', '2' => 'Não'], $coupon->cupUnic ?? null, ['class'=>'form-control', 'parsley-trigger'=>'change', 'required'=>'required']) !!}
It would not be enough to put the 2 (bank value) where it is
nullin the definition ofselect?– Woss
If you put 2 it is "No" but I am not able to make work the check so that if 1 is selected 1 otherwise select 2.
– Marcelo
And how is the database value coming? Is it in some variable? It can only be 1 or 2, or it may not have value either?
– Woss
The value 2 is coming in the variable $Coupon->cupUnic It will only have the value 1 or 2 (Yes and No)
– Marcelo
So if instead of
nullyou put the variable,Simwill be selected from variable 1 andNãowill be if the variable is 2. That’s not what you did?– Woss
I have a field called Unique value that accepts two choices Yes (1) and No (2), the user selects an option (Not for example) but when going to the edit form I want to return the option that the user chose, in the case "No", but it is returning null. I want to do a check to fill in the amount that is coming from the bank.
– Marcelo
How confusing. Who is returning
null? The amount that comes from the database? In question you said that the "2" would be properly coming up to the form, so I believe it is not, but a field of typeselecthas no valuenull. It’s really hard to understand your problem.– Woss
This is a form to register and edit, in case the value is null pq the user will choose the value, after choosing and going to the edit form has q come from the bank the option q he set.
– Marcelo
Let’s go continue this discussion in chat.
– Marcelo