It'd be really great if one could add multiple checkboxes. I really need this, so I tried to implement it on my own (see attached file), using the other flexinode fields as a template.
What I managed to do:
- The administer->content->content types half of the matter is completely fixed. When creating a new content type, one can now choose to add a multiple checkbox, with relative options. The options get stored properly in the database.
- When adding a node of the previously created content type with multiple checkboxes, the various multiple checkbox options show up correctly, before previewing or saving the node. As soon as one previews or tries to save the node, Drupal either displays an error, or stops to work entirely, for the reasons I detail below.
What needs to be done:
(e.g. what doesn't work in the attached code)
- When displaying a created node of the aforementioned content type, we need to show all the multiple checkbox options that were actually selected by the author. However, this is quite hard to do, because of the next issue.
- As far as I know, it is currently not possible to insert into the database what options were actually checked/selected by the author.
This is because the various options themselves get stored into the flexinode_field table, in the options field, but their corresponding value is stored into the flexinode_data table, in the numeric_data field, which is of integer type.
Therefore, if two or more options are selected, I don't think there are ways to store the fact that they were indeed checked into the database. Please correct me if I'm wrong, since my knowledge of php and databases is limited.
Considering that to make this work I think one would need to modify the flexinode_data table, this is as far as I was able to go, as I know too little of databases to try and do the modification myself, and the modification would probably also affect all the other flexinode fields (single checkboxes, selects, etc.).
I hope a better learned someone can make this work, as this would be really an incredibly useful feature.
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | field_multicheckbox_4.inc | 3.26 KB | epicflux |
| #15 | field_multicheckbox_3.inc | 3.14 KB | epicflux |
| #10 | field_multicheckbox_2.inc | 3.05 KB | Wai_Wai |
| #8 | field_multicheckbox_1.inc | 3.04 KB | Wai_Wai |
| #3 | field_multicheckbox_0.inc | 2.94 KB | magnestyuk |
Comments
Comment #1
magnestyuk commentedHi!
Has anyone been able to make this work? I'm also trying to, but with little success.
Comment #2
magnestyuk commentedHere's what I did so far:
--the data gets inserted into the database (I'm using serialized_data)
--the node edit pages display the checked/unchecked boxes correctly
what I don't know is how to display the names of the checked boxes on the node view pages. Currently no multicheckbox data shows, even though there are checked boxes there. Something needs to be done with the flexinode_field_multicheck_format() function, but I don't know what.
You can find what I did so far attached.
Can anyone help find the problem there?
Thanks.
Comment #3
magnestyuk commentedOk, I came up with a perfectly working version that probably needs some code cleanup though.
See it attached.
Comment #4
flufftronix commentedThis only works for me if it's renamed to field_multicheck.inc
Not sure if anyone else was having this problem or not..
Comment #5
buck@civicspacelabs.org commentedI'm trying to use this and I get this error when I add a Multiple checkbox:
warning: Cannot modify header information - headers already sent by (output started at /home/theskate/public_html/modules/flexinode/field_multicheck.inc:87) in /home/theskate/public_html/includes/common.inc on line 192.
Comment #6
spazfoxThis is working great for me! Thanks for the great feature.
Does anyone know how to add the multiple checkboxes to the flexinode search page (similar to how regular checkboxes appear)? Basically what I'd like to see is each checkbox option (from multi checkboxes) appear as a separate drop-down list on the search form, just as regular checkboxes do.
Comment #7
spazfoxI forgot to mention that although this module is working great for me and I don't receive any on-screen error messages, this error message does appear in the logs:
Invalid argument supplied for foreach() in /home/contextu/public_html/modules/flexinode/field_multicheck.inc on line 38.
Comment #8
Wai_Wai commentedI have fixed some minor problems.
This *.inc should be fine now.
I once ran in my Drupal and no error occurred.
Enjoy!
Comment #9
Wai_Wai commentedHi.
Please remember to get rid of the "_1", and rename the file field_multicheckbox_1.inc as field_multicheckbox.inc.
Or it won't work.
Comment #10
Wai_Wai commentedHi.
Just fix another minor bug.
Please remember the file name has to be field_multicheckbox.inc , or it won't work.
Enjoy!
Comment #11
Steve Dondley commentedWhat are you trying to accomplish with the following line:
It causes the first option not to appear on the content creation form.
Comment #12
Bèr Kessels commentedIt needs some brushing up before it can be committed to core.
Also, we are focussing mainly on getting flexinode ready for form API, untill hten we will add no new features.
Comment #13
scroogie commentedSteve Dondley, i think this is a relict from the original file, where a 'none' option was shown as the first option. If the field is required, then it is not allowed to select none, therefor the none-option is removed (through unset).
Comment #14
anawillem commentedWe are also looking at this module with a lot of interest for 4.7. Is there anyone working on this now? I know that Ber mentioned that it still needed too much work to be implemented immediately. Is there anyone out there doing this? It will make the DMS I am creating to match our needs work better.
Comment #15
epicflux commentedI was still getting this error:
Invalid argument supplied for foreach() in /whatever/modules/flexinode/field_multicheck.inc line 49.
(looks like other users have the error occur on different lines, but same bit of code)
To fix this I replaced line 44 (might be a different line in your version):
becomes:
I would get the error after first creating or saving the node, but not when viewing it afterwards. The issue is that (I guess) when you first view a node after creating (or updating) the data is being pulled from the form and not from the database. If it's coming from the form than the checkbox values are still in the form of an array. Anyway, this bit of code just checks to see if the field data is in the form of an array.
This is a great addition to the flexinode module, thanks!
Comment #16
epicflux commentedTo get it work with Previews and when a user leaves the field unanswered it required a few more tweaks.
Do the is_array() check in the flexinode_field_multicheckbox_form function.
Do the is_array() check before inserting the data into the database to keep it from inserting data when the field is left empty.
Check to make sure that $checks is an array to get it to work when the field is left empty.
(I was sure to do a bunch of testing this time, sorry about the previous posting)
Comment #17
Bèr Kessels commentedWe need to fix this in HEAD/CVS too, as far as I can see.
I also need someone to test this on a 4.6 flexinode with data.
And please. Post patches, not the files themselves. If you do not post patches, then you only give us more work, instead of helping unload work. More on patches here: http://drupal.org/diffandpatch
Comment #18
trevornz commentedHi there
I'm using:
field_multicheckbox_4.inc with Flexinode in Drupal 4.6.9.
I'm also using Flexisearch which unfortunitley seems to ignore all content in field_multicheckbox_4.inc.
I'm just wondering if there's a fix available/possible for this. Any advice would be greatly appreciated.
Comment #19
tom611 commentedIs there a field_multicheckbox available for flexinode 4.7? If not, is there something under development? Can't find anything...thanks.
Comment #20
Bèr Kessels commentedNot critical and not a bug.