Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FormField - default attribute changes empty value when editing record (instead only when creating record) #43696

Closed
fuscage opened this issue Jun 24, 2024 · 5 comments

Comments

@fuscage
Copy link

fuscage commented Jun 24, 2024

Steps to reproduce the issue

  • create an article with empty note and save

  • go to the /administrator/components/com_content/forms/article.xml file and add a default value : default="ZZZZ"

  • save the article.xml

  • open the article

Expected result

the value of the note field is : emtpy

Actual result

the value of the note field is : ZZZ

System information (as much as possible)

J4.4.5

Additional comments

@fuscage fuscage changed the title FormField - default attribute changes empty value when editing record (instead only when new record) FormField - default attribute changes empty value when editing record (instead only when creating record) Jun 24, 2024
@brianteeman
Copy link
Contributor

It is working correctly. You have set a default value and that is being used

@fuscage
Copy link
Author

fuscage commented Jun 25, 2024

It is working correctly. You have set a default value and that is being used

Thanks for you reply.
For me, a default value to the field is a value to display to the field when you create a new record, it's a proposition for an enduser.
it's not the same thing that the default value for the database when you receive a null value . If I have a decided to delete the default value to save a null value (because the field is not required), you can't display the default value after loading the record and after I have deleted the value.

Follow this question at an enduser : if you create an record and you see the quantity at 1 (by default), you delete this quantity and you save, what do you excpected ? many endusers will said : "empty result, because I have deleted the value". But the result will be 1...

So, in this case the default value to the field is the default value to the database when you receive a null value. in some case, for me, you want just to propose a value in a field for a new record

@brianteeman
Copy link
Contributor

You are confusing default value and placeholder.

@fuscage
Copy link
Author

fuscage commented Jun 25, 2024

No, I know the difference. the placeholder is not a real value, you need to encode over it : https://www.w3schools.com/tags/att_input_placeholder.asp => The placeholder attribute specifies a short hint that describes the expected value of an input field

for me you are confusing default and required.
for you, you can't remplace a default value for empty? why, if the required is at false?

So in this case if you write a field with a default="ZZZ" value and required=false, it's the same thing that put the required=true :/ it's strange, no?

a default value, it's like you are initalizing a variable, you can delete the value after if you want.

A field it's just a way to an enduser to define a variable with some restrictions : readonly, required, default, ...
required means : you accept or not empty value.
default means : I have initalize the field for you, but you can replace the value, and if you want to delete the value (and you don't receive a warning like the field is required) I accept the value (and NOT I replace the empty value by the initalization value without inform you...)

no problem, that will be nice for joomla to have this difference with the required field, but I have try, no problem

thanks for your time

@Fedik
Copy link
Member

Fedik commented Jun 25, 2024

Thanks for the reaport.
It is expected behavior. It not realy possible to change it.

The Form uses the default value anytime when the field value is empty.
The Form does not know and does not care if it new or existing content.

@Fedik Fedik closed this as completed Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants