When will single select be done?
alanic - October 3, 2007 - 08:30
| Project: | CCK Taxonomy Super Select Ultra |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | alanic |
| Status: | patch (code needs review) |
Description
Great module, but I really need single select. I was able to make it display radio buttons by making it single select through taxonomy module, but when I submitted the form it was like nothing was selected.
Do you have an estimate on when it will be done? I don't think it should be a big deal, since almost everything seems to be in place.
Or could you let me know why it is not working so that I can fix it? I don't have the urge to work all the code by myself to see why it's not working, but if there is a starting point I could.

#1
Since I don't personally need single select for my own projects and have about a gazillion things on my plate right now (startup company), it is way on the back burner. The problem seems to be in the widget-related functions. There are only two or three of them, but I couldn't find the bug(s). If you're unfamiliar with CCK in general, read the sample file that comes with CCK; it's called field.php. That will get you started. Then you can study, uh, what's it called?- Taxonomy Super Select I think - that's one of the modules this is based on and I believe radio buttons work there. The reason it does not work in this module is that I added the ability to have infinite depth for your vocabulary whereas TSS can only have five levels - unless they now use the patches I submitted months ago. If they are using my patches, then perhaps they have code that can be transplanted now. I haven't had time to look at the progress of that module.
Anyway, I would love a patch to fix this just so I can put it to bed. Good luck.
#2
Here is the patch. It's just one line of change but I learned a lot about CCK and Drupal code till I could find it. I tested and it works as expected while creating, editing, previewing and displaying.
singleselect.patch : the patch for single select. to be applied as patch -p0 < singleselect.patch outside of cck_taxonomy_ssu directory.
#3
Also here are two little changes that I think are improvements on code.
#4
Note: singleselect.patch works for required vocabularies. For the vocabularies that are not required, line 662 should be changed like line 677 in the patch, but this is not enough.
When you edit a node that already has a term from the vocabulary, editing it and selecting "Select None" will not remove the term. Also, when editing starts both "Select None" and the previously selected one come selected by default, even though they have the same "name" attribute.
(All this is after changing line 662)
I don't need this now so I'm not spending time on it, but in the future when I'm bored I may fix this.
#5
First a note on procedure here on Drupal.org that I'm sure you're not aware of; you never mark a patch as 'ready to be committed' if you're the one posting it. It must always first be marked as 'code needs review', which of course, is what I'm doing with it.
Second, you may want to know that most projects won't accept patches not in unified diff format, which yours is not. Especially when they get bigger than those you posted. It took me a minute to figure out the syntax of your patches as they are non-standard. Check out the handbooks for how to do them the 'right' way.
Third, I'll test the first patch, but just looking at it, it makes sense. Seems I just never put in the proper amount of effort to figure that one out.
Fourth, at first look, I couldn't believe that the 'view' case wasn't being called. I was sure that it was. But then I remembered that for the last release I decided to do the display correctly and use the default CCK handlers for that, which then bypasses the custom one I had done. So, that's a valid catch and I'll just be deleting it from the code, not commenting it out.
Last, I'll have to check the context of that last change of yours as I have no recollection of that section of code.
You'll also want to know that I seem to recall that I've made a couple of changes myself, though I don't recall what they were. I'll have to look them up. I do know that this module does not work as a field in an nodeprofile content type, so I'm trying to figure out why. It has something to do with the submit function not firing. I got sidetracked with another project, so I'll get back to this when I can. Meanwhile, I'll try to get a new release out with my other fixes and any additions from your patches that I include.
Thanks.
#6
Could you explain the first change in #3? I could have sworn this code was executed during page views.
#7
I just saw this message, is there something I need to do to make this send me e-mails?
The second change is obvious, only unset $items['tid'][0] if $items['tid'] is indeed an array.
The first change, well I put a drupal_set_message() there and tried hard to see when it is being executed and never saw one. It's purely observational:) although I remember having a feeling like it was duplicate logic with some other code somewhere, but it's been a while so I can't remember.
#8
Well I made most of the changes you suggested. I'll have to investigate that 'view' thingy before removing it.
#9
Can i use this patches on my site, or they are not approved?
#10
You could use them safely I think. Note that in the other.patch file, the first section deals with removing some code that supposedly never gets used. I have not verified that it isn't used and that is what I was referring to. The rest of the changes will definitely make it into the next release. I just have to get around to testing this final case to see whether it will as well. So that's why I marked this as fixed, since either way, a solution has been arrived at.
#11
I use patch #1 - and have some problems
1. I need to commnet line
$form['field']['multiple']['#disabled'] = TRUE;
in cck_taxonomy_ssu.module
2. When i use single select - it DOESN'T save tags and when i reopen node for editing every radio is empty!
So i am waiting for official release!
#12
#13
Re: Eugef
If you follow my initial post, I made the vocabulary to be single select through the taxonomy module, not by commenting out that line and enabling that combo box. I didn't write handling code to change single selectedness thru cck. Do it the way I did it and it will work.
#14
Right. The 'Multiple' setting at the CCK level does not produce the ability to select multiple taxonomy terms!!! The CCK-level 'multiple' setting is for having several taxonomies show on your node, which this module definitely CANNOT do.
So in any case, I should be getting a new version out in a couple of weeks (before the new year), so I'll try to get this into it if I haven't already (can't remember).
#15
Subscribing and following progress due to term selection problems.
Greetings, Martijn
#16
I'm readying a new release and will work on this as part of it.
#17
I'm a little stuck. I've managed to get the form for the radio buttons to look identical to the checkbox version, but upon submission, all data not in the top level is just gone. I don't know where it goes. Outputting $form_values first thing at validation shows the data to be gone already.
So currently, you can add freetags with radio buttons selected, but you cannot change the selected button at all since the data disappears.
I may have to release the new version with this still broken. If so, I would love some help on this issue!
#18
Hi
I managed to get the single select working!
The problem was the the radio's didn't have the right parents info. So I changed that in the function: _cck_taxonomy_ssu_branch @ 774 and @ 797
it was:
<?php'#parents' => array($vid),
?>
and I changed it to:
<?php'#parents' => array($field['field_name'] , 'tid', $vid, 'set', 0),
?>
It works if the selection is required. If it is not required and you select 'none' it will give a database error.
I also changed that if there is a default selection (eg, if you edit a node) the fieldset will not collapse by default.
I added a few lines in the function: _cck_taxonomy_ssu_next_nested @ 623
it was:
<?phpif ($tss) {
$term->is_parent = TRUE;
$term->parent_type = $input;
$term->parent_value = $items['default tid'][$term->tid];
if ($items['default choice']) {
$term->choice_value = $items['default choice'][$term->tid];
}
}
$form_branch[$term->tid] = _cck_taxonomy_ssu_branch($field, $vid, $term, $freetag, NULL, NULL, 'fieldset', $fieldweight++);
?>
and changed to:
<?phpif ($tss) {
$term->is_parent = TRUE;
$term->parent_type = $input;
$term->parent_value = $items['default tid'][$term->tid];
if ($items['default choice']) {
$term->choice_value = $items['default choice'][$term->tid];
}
}
foreach ($children as $child){
if (isset($items['default tid'][$child->tid])){
$term->collapsed = FALSE;
}
}
$form_branch[$term->tid] = _cck_taxonomy_ssu_branch($field, $vid, $term, $freetag, NULL, NULL, 'fieldset', $fieldweight++);
?>
This last change does not work if you select a radio in an other fieldset and click preview. Didn't have time to check it out why.
I also attached the whole file.
I hope this will shed some light on the problem.
Kind regards,
Ben