This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

servinseb55487
servinseb55487

So I have a form where you can add and edit pictures. I am trying to make it so that the user can click a button and the image will be deleted. To do this, I am trying to make it so that when they click the button, the value on the DB will become null. However for some reason this is not working. This is how I am doing it: $plant->plantimage = null; $plant->save();

plantimage is where the file goes. Any ideas?

mjauvin
mjauvin

Do you use the FormController behavior? Show some code so we can help.

mjauvin
mjauvin

If this is an attachOne relation in your model, try:

$plant->plantImage()->remove()

1-3 of 3

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.