No Code Attached Yet
avatar fuscage
fuscage
24 Jun 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

avatar fuscage fuscage - open - 24 Jun 2024
avatar joomla-cms-bot joomla-cms-bot - change - 24 Jun 2024
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 24 Jun 2024
avatar fuscage fuscage - change - 24 Jun 2024
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)
avatar fuscage fuscage - edited - 24 Jun 2024
avatar fuscage fuscage - change - 24 Jun 2024
The description was changed
avatar fuscage fuscage - edited - 24 Jun 2024
avatar brianteeman
brianteeman - comment - 25 Jun 2024

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

avatar fuscage
fuscage - comment - 25 Jun 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

avatar brianteeman
brianteeman - comment - 25 Jun 2024

You are confusing default value and placeholder.

avatar fuscage
fuscage - comment - 25 Jun 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

avatar Fedik Fedik - change - 25 Jun 2024
Status New Closed
Closed_Date 0000-00-00 00:00:00 2024-06-25 08:39:11
Closed_By Fedik
avatar Fedik Fedik - close - 25 Jun 2024
avatar Fedik
Fedik - comment - 25 Jun 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.

Add a Comment

Login with GitHub to post a comment