1

I Have the following piece of code that works perfectly.

<div id="priceBloc" class="form-group <?php echo (isset($errors) and $errors->has('price')) ? 'has-error' : ''; ?>">
    <label class="col-md-3 control-label" for="price">{{ t('Price') }}</label>
    <div class="col-md-4">
        <div class="input-group">
            @if ($country->get('currency')->in_left == 1)
                <span class="input-group-addon">{{ $country->get('currency')->symbol }}</span>
            @endif
            <input id="price" name="price" class="form-control" placeholder="{{ t('e.i. 15000') }}" type="text" value="{{ old('price') }}">
            @if ($country->get('currency')->in_left == 0)
                <span class="input-group-addon">{{ $country->get('currency')->symbol }}</span>
            @endif
        </div>
    </div>
    <div class="col-md-4">
        <div class="checkbox">
            <label>
                <input id="negotiable" name="negotiable" type="checkbox" value="1" {{ (old('negotiable')=='1') ? 'checked="checked"' : '' }}>
                {{ t('Negotiable') }}
            </label>
        </div>
    </div>
</div>

However I need a select list item for price symbol so the user can select between two different currency like AUD and USD.

Is there any way I can do this please help me as I am very new to Php Laravel.

2
  • Do you have currency field in your DB? Select options aren't PHP / Laravel by the way, it's general html Commented Nov 6, 2017 at 9:08
  • Yes I do have the currency field in database Commented Nov 6, 2017 at 9:10

1 Answer 1

1

In your controller, get the list of currencies and pass this to your view:

$currencyList = Country::all()->sortBy('currency', SORT_NATURAL | SORT_FLAG_CASE)->pluck('name', 'id');

Then add the select field to your form:

<div class="form-group">
    {{ Form::label('Currency') }}
    {{ Form::select('currency', $currencyList, null, array('class'=>'form-control', 'placeholder'=>'Select currency')) }}
</div>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.