No Code Attached Yet J4 Issue
avatar AndyGaskell
AndyGaskell
5 Aug 2019

User story

I would like to add a checkbox field, with multiple checkboxes, with more than one checked by default.

Steps to reproduce the issue

  • Add a new field in com_fields
  • set the type to "Checkboxes"
  • Add a value with the "Text" set to "apples" and the "Value" set to "apples"
  • Add a value with the "Text" set to "pears" and the "Value" set to "pears"
  • Set the default value to "apples,pears" to match the "rawvalue" that you'd expect
  • Click "Save"

Expected result

The field would save, and in new content items, it would default to have both checkboxes checked.

Actual result

Error
Save failed with the following error: The default value is invalid.

System information (as much as possible)

PHP Built On Linux hp-i5 4.15.0-55-generic #60-Ubuntu SMP Tue Jul 2 18:22:20 UTC 2019 x86_64
Database Type mysql
Database Version 5.7.27-0ubuntu0.18.04.1
Database Collation utf8_general_ci
Database Connection Collation utf8mb4_general_ci
PHP Version 7.2.20-2+ubuntu18.04.1+deb.sury.org+1
Web Server Apache/2.4.29 (Ubuntu)
WebServer to PHP Interface apache2handler
Joomla! Version Joomla! 3.9.10 Stable [ Amani ] 10-July-2019 15:57 GMT
Joomla! Platform Version Joomla Platform 13.1.0 Stable [ Curiosity ] 24-Apr-2013 00:00 GMT
User Agent Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0

Additional comments

This validation logic is in line 278 of "administrator/components/com_fields/models/field.php".

I did some searching and concluded this was a new issue, sorry if I've missed something and this is already reported or resolved.

Looking in 3.10 dev the issue seems to still be there https://github.com/joomla/joomla-cms/blob/3.10-dev/administrator/components/com_fields/models/field.php

I'm happy to try and code up a fix if people agree this is a valid bug.

I guess this is also the case for fields of the type "list" and "list of images", as they also support multiple values.

screen shot 2019-08-05 at 21 31 49

avatar AndyGaskell AndyGaskell - open - 5 Aug 2019
avatar joomla-cms-bot joomla-cms-bot - labeled - 5 Aug 2019
avatar AndyGaskell
AndyGaskell - comment - 5 Aug 2019

Apart from the validation, having multiple default values works fine.

So, if I go and set the value in MySQL manually, like...

UPDATE `o5h9d_fields` SET `default_value` = 'apples,pears' WHERE `o5h9d_fields`.`id` = 15;

...then the form UI works as you'd expect, making both boxes checked by default.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/25785.

avatar AndyGaskell AndyGaskell - change - 5 Aug 2019
The description was changed
avatar AndyGaskell AndyGaskell - edited - 5 Aug 2019
avatar franz-wohlkoenig franz-wohlkoenig - change - 6 Aug 2019
Labels Added: J3 Issue
Removed: ?
avatar franz-wohlkoenig franz-wohlkoenig - unlabeled - 6 Aug 2019
avatar franz-wohlkoenig franz-wohlkoenig - labeled - 6 Aug 2019
avatar franz-wohlkoenig franz-wohlkoenig - change - 6 Aug 2019
Labels Added: ?
avatar franz-wohlkoenig franz-wohlkoenig - labeled - 6 Aug 2019
avatar franz-wohlkoenig franz-wohlkoenig - change - 6 Aug 2019
Status New Discussion
avatar Quy
Quy - comment - 6 Aug 2019

I would consider it as a valid bug. Please submit PR.

avatar AndyGaskell
AndyGaskell - comment - 6 Aug 2019

Thanks @Quy, I'll try code up a fix

avatar tonypartridge
tonypartridge - comment - 12 Aug 2019

I believe this is the same as repeatable fields? You would need {value1,value2} or similar as to how it’s stored in the DB.

I agree that comma separated support would be welcomed too!

avatar macstalker
macstalker - comment - 22 Jan 2021

This issue still exist in Joomla 4b6 and below :( It would be great if you can fix it. I really need this feature. Thanks!

avatar particthistle
particthistle - comment - 30 Nov 2021

@AndyGaskell did you ever come up with a workaround for J3 initially?

I've just tried doing the same thing today, and will be wanting to do so more with Custom Fields in the future, so if you've not made some progress, I'll raise it with Enhancement Team to look at for a fix for Joomla 4.1.

avatar chmst chmst - change - 30 Nov 2021
Labels Added: No Code Attached Yet good first issue
Removed: ?
avatar chmst chmst - labeled - 30 Nov 2021
avatar Siddhesh-Yadav
Siddhesh-Yadav - comment - 4 Dec 2021

I would like to work on this project, can you please help me to set up the project

avatar chmst
chmst - comment - 4 Dec 2021

If you are new to github - start reading documentation here: https://docs.joomla.org/Working_with_git_and_github.

You can for the project in your own repo. Work on branch 4.1 dev.

avatar rjharishabh
rjharishabh - comment - 4 Dec 2021

Hi @Siddhesh-Yadav
If you are new to Joomla,

  1. Set up your development environment https://docs.joomla.org/J4.x:Setting_Up_Your_Local_Environment
  2. Browse Joomla as a naive user, try to create articles, banners, categories etc as well as if you find a valid issue, report it.
  3. Test others' PR and look at PR code and try to understand the code.
  4. Learn Git and Github https://docs.joomla.org/Working_with_git_and_github and try to create PRs
  5. Read Joomla documentation as well as the code to learn more about the project.

You can't understand Joomla in a day or in a week or in a month, it will take time to learn.
So don't give up

Little advice from my side

avatar Siddhesh-Yadav
Siddhesh-Yadav - comment - 7 Dec 2021

Is Joomla going to participate in GSOC 2022,sir? so this will be considered as a valid contribution.

avatar abinash185
abinash185 - comment - 21 Jan 2022

I'm working on it . Please guide me.

avatar adithyareddych
adithyareddych - comment - 28 Mar 2022

@brianteeman Can I work on this issue?

avatar brianteeman
brianteeman - comment - 23 Aug 2022

Can someone please update the labels to change to J4 Issue and to remove the incorrect Good First Issue

avatar zero-24 zero-24 - change - 23 Aug 2022
Labels Added: J4 Issue
Removed: J3 Issue good first issue
avatar zero-24 zero-24 - labeled - 23 Aug 2022
avatar zero-24 zero-24 - unlabeled - 23 Aug 2022
avatar zero-24 zero-24 - unlabeled - 23 Aug 2022
avatar tonypartridge
tonypartridge - comment - 29 Sep 2022

How are you getting on @adithyareddych ?

avatar joomdonation joomdonation - close - 4 Dec 2022
avatar joomdonation
joomdonation - comment - 4 Dec 2022

PR #39354 should fix the issue. Unfortunately, Joomla 3 does not receive regular bugs fixes at the moment, so we can only fix this issue for Joomla 4. Please help testing. Thanks !

avatar joomdonation joomdonation - change - 4 Dec 2022
Status Discussion Closed
Closed_Date 0000-00-00 00:00:00 2022-12-04 06:47:11
Closed_By joomdonation

Add a Comment

Login with GitHub to post a comment