skiab0x
1 month ago
251
6
Laravel

Convert two state input field to drop-down component

Posted 1 month ago by skiab0x

Hello friends. I have a form that gets created after an edit button is pressed. The specific input field is getting only two values, so I want to convert the input field to a select component. Here is the input field:

<input type="text" class="form-control @error('symbol_position') is-invalid @enderror" name="symbol_position" value="{{ old('symbol_position') ?? $currency->symbol_position }}" required>

The two states are the following (from the create form) :

<select class="select2-single form-control @error('symbol_position') is-invalid @enderror" name="symbol_position" required>
                                            <option value="" disabled selected>Choose position</option>
                                            <option value="before" {{ old('symbol_position') == 'before' ? 'selected' : '' }}>Before</option>
                                            <option value="after" {{ old('symbol_position') == 'after' ? 'selected' : '' }}>After</option>
                                        </select>

Please sign in or create an account to participate in this conversation.