Strange Space

I have a modal that I use as an update form. There’s space that keeps popping inside a dmx-bind:value. The preceding inputs have identical structure, however, the last input, if blank should show only the placeholder info. In this case, the input displays a blank input and not the placeholder’s data. All this is caused by a space that is mysteriously placed in the input.

In the attached image you will see the input above is blank and works perfectly. However the last input is the culprit that somehow decided to put a space inside.

Any ideas?

Below is a screen shot of the evidence:

Did you use the Form generator and remove the button?

You could duplicate the row above the mystery and replace the input with the input you want and delete the mystery row, that should all balance out...

Are you sure it’s no your data source returning an empty space as a value? What do you see in the dev tools for this input dynamic value?

Thank Teo, no I’ve checked the database and there are no spaces or characters of any kind.

The input above shows, as it should value. However this one all I see that causes the placeholder to fail is value=" " (as seen in the attached image).

Thanks Dave, yes, that’s exactly what I did. I have stared at this so long, and rewrote it at least three times or more. My eyes are blurred. Ha!

It’s got to be something simple. At the moment I just threw a trim() on it…

Can you post a screenshot of what you see in the dev tools returned for this field?

I mean the data returned from the database, for this input value.

The database is setup to return a NULL when there’s no data (empty). Where would I find the info you are requesting?

In the dev tools > network > xhr when the server action runs.

Well it seems to me the value is exactly and empty space:

Teo, the database appears to have placed a single space in every blank column. I logged in at our host and looked at the phpMyAdmin. I’ve never noted this happening before.

Any suggestions? Other than use a trim() to ignore the initial space?

I only see an empty space in the field i marked on my screenshot above.

I see your mark. However, is it normal for a database to enter a space when the input is empty?
The only recourse will be the use of the trim(). It appears it’s the best fix for this issue.
Thanks Teo for your assistance.

Well there must be a reason for this. Empty input's value is an empty string "" not a space " " so there must be something in your config sending an empty space to the db.

Check your field defaults in case the default field content has been set to a space, if so set it to null

Thanks Hyperbytes for your help! I had already changed the database to NULL. That’s what confused me. This host recently did some updates, but I would not have guessed that every empty table field would have a space. Frankly, it was my first.

Even with NULL as default, the space was relentless! So I just threw a trim() at it and “wa la” – no more space.

Then you should definitely check what and how are you sending to the database :slight_smile:

1 Like