Frontend validation

Feature(s) impacted

The record edition form

Observed behavior

I have a field that:

  • is non-nullable in Postgres
  • has the empty string as default value ("")

The frontend validators prevent me from submitting the edition form if I don’t set a value.

image

Expected behavior

I would like to be able to submit the form and use the default value (empty string)

Workaround

In my code I set the following so that the frontend validation leave me submit the form.

image

Context

  • Project name: Roundtable
  • Team name: Operations
  • Environment name: All
  • Agent (forest package) name & version: latest agent-nodejs
  • Database type: postgres
  • Recent changes made on your end if any: none related, this never worked
1 Like

Hello @Romain_Gilliotte,

Hope you’re doing well :slightly_smiling_face:

Out of curiosity, what’s the interest in your case to have set this field as a non-nullable value but to make it equal to empty string when there is no value?

No reason really, other that this is how the records are created by my customer’s public facing application and I can’t change it.

I don’t have access to neither the source code of the public facing app, nor permissions to do any structural change in the database.

Hey @Romain_Gilliotte :smiley:! I Hope you are doing fine :slight_smile:

Is it during a creation or an edition? :thinking:
Because during the edition, it would be weird to set the defaukt value don’t you think?

Hey @Romain_Gilliotte,

Gotcha!

Well, your use case is pretty special.
I’m creating a bug report to make it fixed at some point.
The priority won’t be very high, fortunately you have a workaround.

Thanks for the feedback.
Cheers!

It is during edition in my case :slight_smile: (the records are already created).

The issue is that when the user open the form to edit something unrelated, they can’t save because of the frontend validation (the field already contains an empty string and is not modified)

I’m doing great :slight_smile:
Happy new year to the forest team!

1 Like

Woops, that’s worst than what I thought.
I’m raising a bit the priority of the bug report.

Thank you Romain and happy new year to you too! :slightly_smiling_face: :tada:

Hey @Romain_Gilliotte,

I tried to reproduce your issue but without success.
Could you share a video reproducing your issue :thinking: ?

I sent your a private message with a link to a screencast :slight_smile:

Our setup:

  • Non-nullable field with default value = “”
  • Agent nodejs (as the frontend validation rules come from the agent)
  • Postgres (maybe not the same implementation depending on driver)

Then:

  • Try to edit any field of the record
  • It should fail in the frontend (without making a request to the agent) because the “Present” validator which is set on the non nullable field

Hello @Romain_Gilliotte,

Thanks for your clarification.

I can surely reproduce.
Could you please precise one thing: you have the exact same issue when creating a record, right?
Or is it a case that is not really used for this company?

We’re on it anyway!
Cheers.

In this particular collection, the records are not created using the admin panel, but by the customer facing application :slight_smile:

So I did not get to actually try creating a new record (the role configuration on forestadmin forbids it).

Still, I’m pretty sure that the issue is the same for creation / edition.

Thanks a lot!
And no hurry… I mean, it’s not like there is no workaround.

It’s just strange.
When I look at the source code, it seems to be handled correctly.

Hello Romain,

A fix has just been released (on the frontend repository actually).
Could you check if everything is working fine now?

Thanks :slight_smile:

I’m still seeing the little * next to the field name saying that the field is required, but it no longer prevents me from saving my changes.

This is OK for my use-case, I’ll remove the workaround I wrote when I have time

Thanks Adrien and Vince (+ whoever actually made the patch) :slight_smile:

1 Like

I’m still seeing the little * next to the field name saying that the field is required, but it no longer prevents me from saving my changes.

Yes that’s because it represents better the DB: the field should not be null, but it’s ok when it actually equals an empty string.

Cheers mate!