Download & Extend

multigrid element type (checkboxes instead of radios)

Project:Webform
Version:7.x-4.0-alpha6
Component:Code
Category:feature request
Priority:normal
Assigned:spiderman
Status:needs review
Issue tags:checkbox, Grid, multigrid, webform

Issue Summary

I created this multigrid component out of dire need. I hope this element works as expected but any feedback and review are very welcome.
This element is created by modifying the code of the grid element.

AttachmentSize
multigrid.inc_.gz3.39 KB

Comments

#1

Status:needs review» needs work

Making a "multigrid" element sounds like a good idea. However, I would much prefer that this is done by simply adding a "multiple" checkbox to the grid component rather than having two components that are 90% the same code. If this can be made to extend the existing grid component I'd be glad to include it.

#2

It significantly needs more work to do it that way but I'll look into it.

#3

Nice.

But I'm also looking for a multigrid that presents any type of field instead of checkboxes/radios, so that you for instance can have both textfields, checkboxes and date fields in the different cells.

I'm thinking two scenarios. The first is the way that grid works today, where you enter in a number of questions and this directly determines the number of "rows" in the grid and the number of options determines the number of additional columns. Like this:

Question: When and where were you born?
Options: When (date); Where (textfield)

Yielding this grid:

When and where were you born? | date  | text

And the other scenario. Where instead you define a question, you leave that for the user herself to fill in. This way she can also determine the number of rows in a grid. Like so:

Options: What (textfield); When (date); Where (textfield)

Yielding the following:

What         | When      | Where          |
[textfield]  | [date]    | [textfield]    |
[add a new row] (guess it has to be some ajax stuff)

Any ideas for this?

#4

Status:needs work» closed (won't fix)

I'm moving this to won't fix as I have no intention of implementing it myself and enthusiasm seems to have wain from the original author. Please reopen if intending to integrate into the existing grid.inc.

#5

Version:6.x-2.0-beta5» 5.x-2.x-dev
Assigned to:mtolmacs» asciikewl
Status:closed (won't fix)» active

I have a client that needs this functionality (I've already installed this multigrid as a stopgap measure).

They are willing to pay me to implement a grid-based numeric and text component.

My main concern is that the way the multiple values per question is stored in this patch is really a bit of a hack. To do it properly will need another field in the database. So like the "no" field in the current webform_submitted_data, but for the columns.

Another concern of mine with the current grid is that if one of the users changes the order of the questions in a webform with data (they shouldn't but they're users) BAD THINGS HAPPEN to the integrity of the data.

What about adding a field called "col" or "column" that will allow for two dimensional data per component and changing the type of "no" to a text value so you can store a text key if appropriate (I saw another issue discussing this).

The next question is if these changes should be made to the current grid component or if it requires a new component. Fundamentally, the current grid component is a one dimensional question (where most of the other components are point values) that LOOKS like a 2D question. What this change will introduce is a 2D component, so it might be better to keep it separate but from an interface/usability point I think it would be better to do them as one.
That is more risky though for existing data.

Lastly, in what version space would be the best to make these changes? Unfortunately the client is in a hurry (hear that before?) and is using webform extensively on live sites. Currently the site is still running D5, but I could probably upgrade to D6 over a weekend.

Please comment on what the best way forward would be

Thanx :)

#6

A lot of this sounds like good improvements. I'd be very happy to convert some of the existing data. I know that some components (like "date") could benefit from text-based keys rather than numeric. Adding another column is a tricky proposal. Since that would probably mean the data returned from _webform_submit_[component_name] would need to change (how do we know when the data is 2 dimensional or not? Some components like file.inc already return and store an array in the data column.)

Another concern of mine with the current grid is that if one of the users changes the order of the questions in a webform with data (they shouldn't but they're users) BAD THINGS HAPPEN to the integrity of the data.

Another challenging problem. The only real solution to this is to absolutely force all questions/options to have keys. Of course users don't *like* using keys, since they never see them on the output of the form. I've largely solved this in Form Builder by making a prettier JS interface that auto-keys choices. The downside being it'll make specifying custom keys pretty much impossible. Ah well. Okay well I think that's a different problem than the original request.

Lastly, in what version space would be the best to make these changes? Unfortunately the client is in a hurry (hear that before?) and is using webform extensively on live sites. Currently the site is still running D5, but I could probably upgrade to D6 over a weekend.

Both versions are maintained in-sync, so you'll have to write one for both. ;) Fortunately component development is nearly identical between versions, so whichever you develop for it can be ported in a few minutes.

#7

subscribe

#8

subscribing

#9

Is this idea still alive? Why d5 and not d6? Might I change the version here?

#10

I'd still like to see it. I have a few forms I just can't have in drupal for this reason. And, I second the vote for d6.

#11

Version:5.x-2.x-dev» 6.x-2.x-dev

I am changing the version to 6.x-2.x-dev

#12

Subscribe, but not hoping for much here :-/

#13

subscribe

#14

I would definitely like to see the availability of being able to select multiple columns per row in a grid. For example, to check off who is using a list of social media tools, without having to ask does this group use these tools over and over again for each group type. FYI - I am using webforms 6x-3.2

Thanks!

AttachmentSize
multigrid.pdf 124.55 KB

#15

Version:6.x-2.x-dev» 6.x-3.x-dev
Status:active» postponed

I don't have any plans to add this feature currently. Patches appreciated if you're interested in this functionality. Marking postponed because I won't be writing this functionality personally.

#16

subscribe

#17

I've started a multigrid patch, but being new to coding and module development I'm in need of a bit of advice. Through small modifications to grid.inc, I've got the admin side working so that there's a checkbox for multigrid on the grid settings page, and when ticked the grid element in the form updates to checkboxes.

Upon submitting a form with multigrid, I get the following warning:
mysqli_real_escape_string() expects parameter 2 to be string, array given in (...)/includes/database.mysqli.inc on line 323.

Additionally the 'X's are not showing up in the display view to indicate the boxes that were ticked.

I'm reviewing the grid.inc and select.inc files for clues about how to proceed, but it's still a bit beyond me. Any advice is much appreciated.

My modified grid.inc file is attached for reference as a tgz.

AttachmentSize
grid.tgz 3.27 KB

#18

anyone make it?

#19

I can't make it work on Drupal 7.2

I put the multigrid.inc into /drupal/modules/webforms/components/ and I can't see the option when I'm creating a new component.

Any suggestions?

#20

Input from the Webform maintainers appreciated re the quality of |_h2o_|'s work would be very welcome.

Interested in particular in whether (a) it's ready for use, in which case (b) some instructions on how to install (is it a patch?) - or, if it's not read to go, whether someone wants to get it to the point where it can be made ready to go.

#21

One of my clients asked the same question, and I'm working on a solution, based on the code of version 6.x-3.11.
So far, submission of the form works, and values are stored in the database. Displaying the submitted results in e-mail and results (table, submission view) does not work yet.

As far as I understand from the webform code, the radio grid is stored in the same way as the values of a checkbox: 1 value per row, multiple rows, so basically a 1-dimension array. @quicksketch, is this correct?
For the multigrid, a 2-dimensional array is needed (multiple values per row, multiple rows). In my first attempt, I've stored the multiple values per row as an imploded array of the keys. Don't know if this is the best approach.
Any ideas or suggestions?

#22

Okay, here is my modified grid.inc. In this version, I've serialized the values from multigrid, to store the data in a similar fashion as the 'normal' grid: 1 serialized value for every question in the grid.
One issue: displaying the results in the submission e-mail isn't working, and I can't figure out where to fix this. To be honest, it wasn't a priority for the client, so I've concentrated on the other functions. Any help on this subject is appreciated.
I hope this multigrid is working for you.

AttachmentSize
grid.inc_.zip 4.78 KB

#23

thank you so much it is working fine !

#24

hi,

there's an issue (at least for me) with this component.
If i create more than 7 grids, then i get an HTTP 500 error (it seems the webform can't be generated...)

Have you met also this problem ?

#25

My initial guess would be that you're running out of available memory for your php process. Check the web server error logs and have a look at these:

http://drupal.org/node/207036

Or put in your settings.php:
ini_set('memory_limit', '128M');

128M is just an example, you'd have to look at your setup to see what it is currently and increase it from there.

#26

thanks
i have increased the ini_set('max_execution_time', '120'); (my memory was already 128M)
So now it loads but it is quite slow to load...
Do you know how i could improve that ?

Thanks !

#27

Hi,

i have a new problem : when i display the table of results, i get the following error :

in_array() expects parameter 2 to be array, boolean given in /var/***/htdocs/sites/all/modules/webform/components/grid.inc on line 471.

#28

Hi Sophie,

There were some minor changes in the original grid.inc between versions 6.x-3.11 and the current version 6.x-3.14. Here is the multigrid version for webform 6.x-3.14. Probably this will fix your error.

Regarding the speed for creating the multigrids: if you test your page on a separate testing site, but instead of multigrids you make them the original grids with radio buttons, is there a big difference in performance? I don't know how big your grids are, but 7 on one page is quite a lot.

AttachmentSize
grid.inc-6.x-3.14.zip 4.81 KB

#29

you can have a look at webform table element

#30

has anyone had any luck implementing this with d7?

#31

webform table element has a D7 version.

#32

webform table element is a little overkill for what I need to do. It also doesn't provide my users with a readable results table.

#33

Assigned to:asciikewl» spiderman
Status:postponed» needs review

Following on from comment #28, I've re-rolled a patch against grid.inc in 6.x-3.x which seems to work as desired. The only piece that doesn't work at the moment is the "analysis" tab, which doesn't appear to be adding up the options properly at present. This is probably a minor issue with the _webform_analysis_grid() function which I took directly from the above patch, but I don't need this functionality so not putting much energy into fixing it at present. Viewing submissions, viewing the table of submissions, and downloading results all work properly for the new "multigrid" component option. Review/testing welcome!

AttachmentSize
multigrid-886014-33.patch 16.52 KB

#34

Version:6.x-3.x-dev» 7.x-4.0-alpha6

I'm working in Drupal 7 with the alpha version of Webform 4, I love this module. However, I really, really, really need the checkbox option in grids. I'm building a skills survey and have a need for employees to be able to check their level of experience as well as their level of interest. Can I get an updated patch for this function that will work with drupal 7 and webform 4? I'd really appreciate it!!

#35

#34: The webform table element has a D7 version, and should be able to do what you want.

#36

Maybe I'm missing something. I've tried out table element and it doesn't do what I'm wanting, or at least not without a huge amount of effort. I have about 10 pages of skills in grids (small sample attached), probably close to 500 skills total. It seems that in order for table element to do what I want I'd have to create every line of skills as it's own select option. Is there something different you can see?

Thanks much!

AttachmentSize
skillsSample.png 61.36 KB

#37

You're right, webform table element will only help you making the columns and doing the table layout, so you'll end up creating a lot of select options.

I think the best approach is to override the webform output, just create a webform with a select element (containing the column names) for each row, and use form_alter to render them as radio buttons. You'll probably need to implement the pre_save to make sure the save receives the data in the right format.

#38

The Drupal 7 version of webform table layout has some significant problems (the latest release doesn't really work; maintainer has not responded for about 3 weeks). It would really be nice if there was a "multiple" option for grid (as there is for select options) that would use checkboxes rather than radio buttons. I do not understand the reason for restricting grid to radio buttons.

#39

If you want to duplicate the layout of a grid and are not tied to the backend machinery of the grid component, Webform Layout module is a possible solution.

nobody click here