Success

User tests: Successful: Unsuccessful:

avatar Achal-Aggarwal Achal-Aggarwal - open - 21 Feb 2014
avatar Bakual
Bakual - comment - 21 Feb 2014

Hmm, not sure I agree here.
A value in a field only makes sense when you are not supposed to change the value. Mostly used for hidden fields.
For fields where you can change the input, value doesn't make any sense to use as it should override the actual stored value. If you need to define a default value, you use default.

Or what is the issue you try to solve here?

avatar Achal-Aggarwal
Achal-Aggarwal - comment - 22 Feb 2014

As I saw it earlier is if a default value is provided in xml then it is just a default value and what ever comes from post request goes into value. Since in 3.2 we have to maintain backward compatibility so I mapped value and default attr from xml to default property of a field.

But it seems I placed it wrong and also forgot to add its test.

avatar Bakual
Bakual - comment - 22 Feb 2014

As I saw it earlier is if a default value is provided in xml then it is just a default value and what ever comes from post request goes into value .

To my knowledge it was always like this. value never acted as default value. It would be my understanding that if a value is set in the XML, the value coming from the database would be overwritten by it. Imho it only makes sense for fields where the user isn't supposed to change anything (like hidden fields), but there default works as well. Imho, value isn't even a supported attribute for a form definition.
So I don't understand what you try to achieve here. Or I miss something.

avatar Achal-Aggarwal
Achal-Aggarwal - comment - 22 Feb 2014

value is valid attribute in just only one field Checkbox (not even hidden field).
Take a look on http://docs.joomla.org/Checkbox_form_field_type

I think all confusion starts from that only. There value is value and default is checked or unchecked. IMO using default to signify check or uncheck is not intuitive at all.

I was trying to achieve that we already have done, saw that now. https://github.com/joomla/joomla-cms/blob/staging/libraries/joomla/form/form.php#L1755

https://github.com/Achal-Aggarwal/joomla-cms/compare/check-default
How does it looks now?

avatar Bakual
Bakual - comment - 22 Feb 2014

Ah that's true, because the checkbox (which is a strange form element anyway) behaves more like an option than a element and it indeed doesn't seem to take the value there.
Default values on the other hand don't work reliably for checkboxes. Simply because of the way checkboxes are sent by the browser - you only get the checked ones and the unchecked ones just don't exists in POST. So you don't know if it wasn't present in the form or if it was unchecked. It's behaves more like a list where you can select multiple items.

Anyway, it needs to be fixed in the checkbox formfield and not in the generic formfield.

avatar Achal-Aggarwal Achal-Aggarwal - change - 23 Feb 2014
Title
Fix [#33325] Value doesn't evaluated as default
Fix [#33325] Value doesn't evaluated as default
Status New Closed
Closed_Date 0000-00-00 00:00:00 2014-02-23 11:35:57
avatar Achal-Aggarwal Achal-Aggarwal - close - 23 Feb 2014
avatar Achal-Aggarwal Achal-Aggarwal - close - 23 Feb 2014

Add a Comment

Login with GitHub to post a comment