I'm using content_taxonomy as a list of checkboxes. No default is selected, and the field is not required. However, when the form is submitted, term ID 1 is selected despite the checkbox not being ticked. When the form is reloaded, the checkbox for Term ID 1 is ticked.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | content_taxonomy_options_value.patch | 774 bytes | the greenman |
Comments
Comment #1
buddaThis is causing bad data to be populated in forms.
Comment #2
maszkos commentedThis was my problem too.
It is my solution, but in this case you will be unable to use the term with ID 1...
In content_taxonomy.module change this line (133.):
to
Comment #3
buddaNot a great solution, especially as we've already got a lot of data using TID 1 in the system.
I can't see a solution to unset TID 1 either, because in some cases the user might actually want to select TID 1 in the form. argh.
Comment #4
maszkos commentedSome SQL update in correct tables (change TID 1 to other) and everything'll ok.
Comment #5
the greenman commentedWe have done some deeper digging into this issue. It's not a simple one, and we dont yet have a definate answer. We can offer a better fix for now, and will investigate more as to the real cause of this.
The fix: initialise #value within the field definition. Some element in CCK seems to be looking at the field definition and thinking that no value is assigned, it goes and adds "#value => 1" to the field. I have set "#value = array()" with what seem to be good results.
Here is an example:
content_taxonomy_options line 109 (approx, i have debug code all over my module at the moment):
Comment #6
the greenman commentedHere is a small patch. It's been tested on checkboxes. I have not applied anything to selects.
Comment #7
the greenman commentedNope. After a little testing, this fix does not work.
We have just gone with the delete of term 1. It makes no real impact on the workings of the site. I really don't think this needs to be seen as critical.
We would really like to know where this comes from though. It's an interesting one.
Comment #8
Anonymous (not verified) commentedI've noticed key errors upon insertion of nodes as a result of this bug. Even though I don't happen to have a term with tid = 1, I will often see after editing a node that I'll get an error saying that a row wasn't inserted because the key already exists on the term_node table. The key is (tid, nid) on the term_node table in Drupal 5, and the errors are always on the bug rows where tid = 1.
Comment #9
bwo commentedWith:
if ($tid and $tid != 1) {the term with tid=1 doesn't get selected while submitting the form without checking any term, but when you check any term(s), submit, and then try to edit again and unselect all terms, it will not be possible. What I did was to change the line to:
if ($tid != 1) {It works OK now.
Comment #10
llribas commentedPlease,someone could explain me this last solution about:if ($tid != 1) {I don't know how to fix it, where to put thisifor whatelse.sorry..
Comment #11
pcorbett commentedThe $tid != 1 works for me too... I'm going to try and find a better solution -- unless someone already has?
Comment #12
llribas commentedI really will appreciate a new solution.
My versions:
- drupal 5.14
- cck 5.x-1.10
- content_taxonomy 5.x-1.x-dev
After lots of test:
1. The solution of
'#value' => array()seems to work, but when I go to edit an existing node, all the content_taxonomy fields (checkboxes) get unselected, so you have to remember selected options and reselect it. INVALID for me, so there are lots of checkboxes.2. The solution of
$tid != 1doesn't work for me. I don't see any effect from that hack, just a php warning: warning: Illegal offset type in /www/drupal-5.14/includes/form.inc on line 1243. But the tid=1 still seems to get selected (actually in the database, table term_node, the tid=1 is not stored for that node), but apears in node view page.I can't figure out why doesn't work for me, it's suposed to be a valid workaround in this case, so tid=1 is from a vocabulary that doesn't have a content_taxonomy field.
I did:
in content_taxonomy.module, line 133, replaced:
if ($tid) {for
if ($tid !=1) {and the same in line 140, so like I supose, if you select "save both" (cck, and taxonomy tables) the elseif (line 138) is the code. (I also tested changing only the 133 line, the effect is same).
¿Am I doing something wrong? ¿Am I aplying wrong the
$tid !=1solution?I really need to get this working, with any working solution!!
Thanks
Comment #13
llribas commentedOk, digging more in this issue I found:
- The php warning I mentioned, it's not from content_taxonomy.
- I solved replacing the taxonomy with id=1 for another new one. As the incremental SQL type in the database for the tid, a taxonomy will never get the id=1 anymore... so... no problem.
thx
Comment #14
magnus commentedCleanup of old issues. According to maintainer: "active development is only done for the 6.x branch! 5.x is not supported any more".
Reopen issue if problem still exist in 6.x branch.