The Wayback Machine - https://web.archive.org/web/20220722170706/https://github.com/joomla/joomla-cms/issues/25785
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

In com_fields, cannot set multiple default values for the field type checkbox #25785

Open
AndyGaskell opened this issue Aug 5, 2019 · 12 comments
Open
Labels
good first issue J3 Issue No Code Attached Yet

Comments

@AndyGaskell
Copy link
Contributor

@AndyGaskell AndyGaskell commented Aug 5, 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

@AndyGaskell
Copy link
Contributor Author

@AndyGaskell AndyGaskell commented Aug 5, 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.

@Quy
Copy link
Contributor

@Quy Quy commented Aug 6, 2019

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

@AndyGaskell
Copy link
Contributor Author

@AndyGaskell AndyGaskell commented Aug 6, 2019

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

@tonypartridge
Copy link
Contributor

@tonypartridge tonypartridge commented Aug 12, 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!

@macstalker
Copy link

@macstalker macstalker commented Jan 22, 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!

@particthistle
Copy link
Member

@particthistle particthistle commented Nov 30, 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.

@chmst chmst added the good first issue label Nov 30, 2021
@Siddhesh-Yadav
Copy link

@Siddhesh-Yadav Siddhesh-Yadav commented Dec 4, 2021

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

@chmst
Copy link
Contributor

@chmst chmst commented Dec 4, 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.

@rjharishabh
Copy link
Contributor

@rjharishabh rjharishabh commented Dec 4, 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

@Siddhesh-Yadav
Copy link

@Siddhesh-Yadav Siddhesh-Yadav commented Dec 7, 2021

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

@abinash185
Copy link

@abinash185 abinash185 commented Jan 21, 2022

I'm working on it . Please guide me.

@adithyareddych
Copy link

@adithyareddych adithyareddych commented Mar 28, 2022

@brianteeman Can I work on this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue J3 Issue No Code Attached Yet