{% extends "base.html" %}

{% block title %}
About Us - My Flask App
{% endblock %}

{% block content %}
<h1 class="h3 mb-3">銘柄 更新</h3>

    <!-- フラッシュメッセージの表示部分 -->
    {% with messages = get_flashed_messages(with_categories=true) %}
    {% if messages %}
    <div class="mb-3">
        {% for category, message in messages %}
        <div class="alert alert-{{ category }} alert-dismissible fade show" role="alert">
            {{ message }}
            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
        </div>
        {% endfor %}
    </div>
    {% endif %}
    {% endwith %}

    <div class="row">
        <div class="col-xl-12 col-xxl-5 d-flex">
            <div class="w-100">
                <div class="card">
                    <div class="card-body">
                        <form action="{{ url_for('update', id=stock.id) }}" method="POST">
                            <div class="mb-3">
                                <label for="code" class="form-label">code</label>
                                <input type="text" class="form-control" id="code" name="code" value="{{ stock.code }}"
                                    required>
                            </div>
                            <div class="mb-3">
                                <label for="name" class="form-label">name</label>
                                <input type="text" class="form-control" id="name" name="name" value="{{ stock.name }}"
                                    required>
                            </div>
                            <div class="mb-3">
                                <label for="memo" class="form-label">memo</label>
                                <input type="text" class="form-control" id="memo" name="memo" value="{{ stock.memo }}">
                            </div>

                            <button type="submit" class="btn btn-warning">Update</button>
                            <a href="{{ url_for('list_view') }}" class="btn btn-secondary">Cancel</a>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

    {% endblock %}