<% layout('layouts/boilerplate') %>
    
    <div class="row">
        <h1 class="text-center">Edit Campground</h1>
        <div class="col-md-6 offset-md-3 mb-3">
            <form action="/campgrounds/<%= campground._id %>?_method=PUT" method="POST" novalidate class="validated-form"
                enctype="multipart/form-data">
                <div class="mb-3">
                    <label class='form-label' for="title">Title:</label>
                    <input class="form-control" type="text" id="title" name="campground[title]" 
                    value="<%= campground.title %>" required>
                    <div class="valid-feedback">
                        Nice title!
                    </div>
                </div>
                <div class="mb-3">
                    <label class="form-label" for="location">Location:</label>
                    <input class="form-control" type="text" id="location" name="campground[location]"
                    value="<%= campground.location %>" required>
                    <div class="valid-feedback">
                        Looks good!
                    </div>
                </div>
                <div class="mb-3 custom-file">
                    <label for="image" class="form-label">Add image(s):</label>
                    <input class="form-control custom-file-label" type="file" id="image" name="image" multiple>
                </div>
                <div class="mb-3">
                    <% campground.images.forEach(function (img , i) { %>
                        <img src="<%= img.thumbnail %>" class="img-thumbnail" alt="">
                        <div class="form-check form-switch">
                            <input class="form-check-input" type="checkbox" role="switch" id="image-<%= i %>"
                            name="deleteImages[]" value="<%= img.filename %>">
                            <label class="form-check-label" for="image-<%= i %>">Delete?</label>
                        </div>
                        
                    <% }) %>
                </div>
                <div class="mb-3">
                    <label class="form-label" for="price">Price:</label>
                    <div class="input-group">
                       <span class="input-group-text" id="price-label">$</span>
                       <input type="text" class="form-control" id="price" placeholder="0.00" aria-label="price"
                       aria-describedby="price-label" name="campground[price]" value="<%= campground.price %>" required>
                       <div class="valid-feedback">
                            Looks good!
                        </div>  
                    </div>
                </div>
                <div class="mb-3">
                    <label class="form-label" for="description">Description:</label>
                    <textarea class="form-control" type="text" id="description" name="campground[description]" required>
                        <%= campground.description %>
                    </textarea>
                    <div class="valid-feedback">
                        Very well!
                    </div>
                </div>
                
        
                <div class="mb-3">
                    <button class="btn btn-info">Update Campground</button> 
                </div>
        
            </form>
        
        
            <a class="btn btn-danger" href="/campgrounds/<%= campground._id %>">Back to campground</a> 
        </div>
    </div>
