fix: admin photo fields -> TextInput + ImageColumn (FileUpload foreach 500 gone); user upload syncs photo_url input so Save keeps the photo; ProductResource photo added
This commit is contained in:
@@ -228,7 +228,9 @@ func (a *App) UploadPhoto(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||||
fmt.Fprintf(w, `<div><img src="%s" alt="Uploaded photo" class="mb-2 h-32 w-32 rounded-lg object-cover"><p class="text-xs text-green-700">Photo uploaded ✓</p></div>`, photoURL)
|
// Update the main form's photo_url input so a subsequent Save keeps the photo,
|
||||||
|
// and show the thumbnail. htmx executes the inline script on swap.
|
||||||
|
fmt.Fprintf(w, `<div><img src="%s" alt="Uploaded photo" class="mb-2 h-32 w-32 rounded-lg object-cover"><p class="text-xs text-green-700">Photo uploaded ✓</p><script>var i=document.querySelector('input[name="photo_url"]'); if(i){ i.value='%s'; }</script></div>`, photoURL, photoURL)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CloseTag lets an owner close (retire) their tag. Data is kept; the tag page
|
// CloseTag lets an owner close (retire) their tag. Data is kept; the tag page
|
||||||
|
|||||||
Reference in New Issue
Block a user