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

intosite
intosite

How can i clear a color picker values so that it saves a null value to the record?

Crazymodder
Crazymodder

Hi,

You can define a column as nullable in your migration like this:

$table->string('color')->nullable();

if you do not populate value it will be null. Also you can make somethink like that in your save method

$model->color = null;

Regards Crazymodder

intosite
intosite

Hi my DB field is already nullable. Just that the form widget colorpicker, does not have an option to select or set to null. Thus even in the save method, it won't know it is null, as there will still be a value in there.

Crazymodder
Crazymodder

If you need a form widget where you have a checkbox with somethink like "no color" you can create your own one and use it. Ocotber is very flexibel if you need to do such thinks.

Regards Crazymodder

intosite
intosite

Yes that is one of the possible methods. Though it's not very good user experience that they have to select something else just to set the color to null, or if was null and then they decide to have a color, to have the front end update that checkbox state.

It'll be much simpler if the function was built into the pre-populated color chips displayed and the user just select that instead.

1-5 of 5

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