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.

Comments

quicksketch’s picture

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.

mtolmacs’s picture

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

mflage’s picture

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?

quicksketch’s picture

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.

asciikewl’s picture

Version: 6.x-2.0-beta5 » 5.x-2.x-dev
Assigned: 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 :)

quicksketch’s picture

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.

georgedamonkey’s picture

subscribe

amir simantov’s picture

subscribing

amir simantov’s picture

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

georgedamonkey’s picture

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.

amir simantov’s picture

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

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

geerlingguy’s picture

Subscribe, but not hoping for much here :-/

crosputni’s picture

subscribe

wheels394’s picture

StatusFileSize
new124.55 KB

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!

quicksketch’s picture

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.

dgastudio’s picture

subscribe

Anonymous’s picture

StatusFileSize
new3.27 KB

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.

naunet’s picture

anyone make it?

l_h2o_l’s picture

Issue tags: +checkbox, +Grid, +webform, +multigrid

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?

quid.oblitus’s picture

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.

jurveen’s picture

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?

jurveen’s picture

StatusFileSize
new4.78 KB

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.

SophieG’s picture

thank you so much it is working fine !

SophieG’s picture

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 ?

asciikewl’s picture

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.

SophieG’s picture

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 !

SophieG’s picture

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.
jurveen’s picture

StatusFileSize
new4.81 KB

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.

attiks’s picture

you can have a look at webform table element

laroccadahouse’s picture

has anyone had any luck implementing this with d7?

attiks’s picture

webform table element has a D7 version.

laroccadahouse’s picture

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.

spiderman’s picture

Assigned: asciikewl » spiderman
Status: Postponed » Needs review
StatusFileSize
new16.52 KB

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!

wendymc’s picture

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!!

attiks’s picture

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

wendymc’s picture

StatusFileSize
new61.36 KB

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!

attiks’s picture

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.

aaronpinero’s picture

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.

aaronpinero’s picture

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.

quicksketch’s picture

Status: Needs review » Needs work

Thanks @spiderman for making a patch! We certainly aren't going anywhere otherwise.

+      if (!empty($element['#webform_component']['extra']['multiple'])) {

We should avoid checking a #webform_component property. Such dependencies on the component array make abstraction difficult and make it impossible to work with Form Builder. Instead we should add a #multiple property on the grid element and check that everywhere instead.

+        // Handle options that are added through the "other" field.
+        // Specifically exclude the "select_or_other" value, which is added by
+        // the select list.
+        elseif ($component['extra']['other_option'] && module_exists('select_or_other') && $option_value != 'select_or_other') {
+          $return[$key][] = $option_value;
+        }

This pretty clearly was copied from select.inc, but we don't have select_or_other support on grid questions, so this code is unnecessary. There is probably a lot of trimming up that could happen with these copy/pasted sections.

And this patch needs to be update for the 7.x-4.x version. No new features are going into the 3.x version.

krisrobinson’s picture

Subscribing to this...

lidiia.litovko’s picture

I need a multivalue grid which checkboxes instead of radios for Drupal 7. Does anybody have a patch or grid.inc file for drupal 7?

tlash’s picture

Issue summary: View changes

would love this too. any other solution out there for 7.4 version of webform?

littledynamo’s picture

Status: Needs work » Needs review
StatusFileSize
new15.29 KB

I've created a patch against 7.x-4.x using @spiderman's patch as a basis and incorporated the feedback from @quicksketch in #40. I've tested the functionality and submissions, results, analysis and download all appear to be working.

Status: Needs review » Needs work

The last submitted patch, 44: webform-multigrid-248690-44-D7.patch, failed testing.

littledynamo’s picture

Version: 7.x-4.0-alpha6 » 7.x-4.x-dev

Wrong version ... should be 7.x-4.x-dev

Status: Needs work » Needs review

The last submitted patch, 33: multigrid-886014-33.patch, failed testing.

littledynamo’s picture

Just for clarity - Patch 44 has passed testing (see top of page). Patch 33 testing was triggered automatically and it failed because it's a D6 patch.

littledynamo’s picture

Assigned: spiderman » littledynamo
danchadwick’s picture

Issue tags: -checkbox, -Grid, -webform, -multigrid

This looks promising. It would be great if a few people could try it out, possibly for 7.x-4.1.

mostovoy’s picture

Hi

I need to hire someone to help me install multigrid on a form. If anyone is Interested contact me. Regards!

badrun’s picture

Have you try this module?

Webform Matrix Component
https://www.drupal.org/project/webform_matrix_component

grimreaper’s picture

Hello,

I just test the patch in comment 44 on webform 7.x-4.1, I can only check the first checkbox per row.

Thanks for the patch.

littledynamo’s picture

Assigned: littledynamo » Unassigned

I'm really busy just now so am struggling for time to update the patch. The complexity of the project I was working on outgrew the grid component, so I didn't end up using it in production.

If someone else wants to try and get the patch over the line then go for it! :)

danchadwick’s picture

Status: Needs review » Needs work
danchadwick’s picture

Version: 7.x-4.x-dev » 8.x-4.x-dev
Status: Needs work » Active

I am not in favor of forcing this feature into the current webform schema (webform_submissions), which is what this and the webform_matrix_component modules do. A new column or two needs to be added to the table, and this probably requires bumping the version to -5.x, which isn't going to happen anytime soon. Accordingly, I'm moving this to the 8.x queue because I think the 8.x schema should support

a) multiple values per question,
b) multiple questions per component delta
c) multiple component deltas per component (e.g. Add another, or provide 5 files/numbers/grids, etc).

fenstrat’s picture

Status: Active » Postponed
Related issues: +#2453511: Define data storage schema for webform 8.x.

So to get this working depends on schema change, so adding the related issue #2453511: Define data storage schema for webform 8.x..

Fine with this happening in D8, but it isn't a priority now, postponing.

danchadwick’s picture

Find to postpone, but I think the schema should change before the first stable release of the D8 version is released. There will never be a better time to address the shortcomings of the current schema.

fenstrat’s picture

Couldn't agree more. Right now I'm using my limited time to try and get 8.x into some working order. Looking forward to tackling larger tasks like schema changes and very much see them happening before a stable release in 8.

emi_bcn’s picture

Hi everyone,
I have modified the patch to make it work on latest Webform 7 version, 7.x-4.10 , without schema change. I can post the patch here if anyone is interested. I'd like a lot to have it working on some Webform 7 version, without having to adapt the patch every time Webform is updated. I think an schema change can be good, but it's not necessary, so we can write an update function to maintain the multigrid whenever the schema change is done. I will have to do so for my clients, so I can take this responsibility, if the maintainer wants to.

And yes, I've tried Webform Matrix Component and does not do the work as well as this patch does.

Thank you a lot for all the good work done!
emi

danchadwick’s picture

I'm not thrilled how this is shoehorned into the existing schema. The core issue is that the "no" column is used as both a delta (multiple values, perhaps ordered) and a subkey (currently only in grids, as the question key).

I really don't see tackling this before D8, and I don't want to have to write a potentially very difficult update function. It may be very hard to find the shoehorned values and convert them to a new schema, requiring the batch api.

vako’s picture

@emi_bcn, please post the patch. I would love to take a look at it and test it.

vako’s picture

Can anyone tell us if any of the patches on this post will enable checkboxes on a grid option?

danchadwick’s picture

I'd try #44, with the understanding that you WILL break your database at some point if/when this feature is incorporated into core. I don't recommend this.

emi_bcn’s picture

Hi again,
@Vako : Yes, the patch i'm going to post today enables checkboxes on a grid element.

@DanChadwick : You said this feature will not be incorporated until version 8.x, at least. We will have time to create a good data migration tool until we have to migrate our D7 to D8. I will have to do it for my clients, so I pledge I will make it public here. So this patch WOULD break the database ONLY if not applying the patches correctly.

Cheers,
emi

vako’s picture

@emi_bcn, thanks. Will you be posting the patch under this post or the main queue?
Since applying the patch is critical, would it be possible to post or email me the actual modified file instead?

emi_bcn’s picture

StatusFileSize
new5.63 KB

Hi @Vako,
Here is the grid.inc complete file (patch applied). You must download it, unzip and overwrite webform/components/grid.inc . I've done this just today for the last webform version, so if you find a bug, tell me.

Hope it helps,
emi

vako’s picture

Thank you very much, perhaps we should create another post for test results or a new issues queue?
It works great upon initial testing, I just noticed that if we are using Webform Report, then the results are coming up as follows:
a:2:{i:0;s:3:"Option1";i:1;s:1:"Option3";},a:2:{i:0;s:3:"Option1";i:1;s:2:"Option2";},a:1:{i:0;s:1:"Option3";},a:3:{i:0;s:3:"Option1";i:1;s:2:"Option2";i:2;s:1:"Option3";},a:2:{i:0;s:2:"Option2";i:1;s:1:"Option3";},a:1:{i:0;s:1:"Option3";}

Instead of:
Option1, Option3
Option1, Option2
Option3
Option1, Option2, Option3
Option2, Option3

I will continue testing in November, since I will be away in October.

danchadwick’s picture

Version: 8.x-4.x-dev » 7.x-4.x-dev
Status: Postponed » Closed (duplicate)

Now implemented as nested multiple select components under a grid. See related issue.

vako’s picture

Thank you Dan. You have done a fantastic job, now we have ability to create not only checkboxes, but any other component under a grid!!

Please see https://www.drupal.org/node/2581891#comment-10463723 for more details.

Here's a quick explanation of how to create checkboxes under a Grid:

  1. Create a Grid component
  2. Create a Select component as Multiple select
  3. Put the Select under the Grid (indent)

Similarly you can add any other component under the Grid to make a more complex grid.

emi_bcn’s picture

Hello Dan!
Great Job!! This patch is really nice, and I can finally deprecate the other one. Finally, I can upgrade this module without applying the patch!!

Thanks a lot!!