Closed (duplicate)
Project:
Drupal core
Version:
6.x-dev
Component:
poll.module
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
13 Nov 2005 at 23:51 UTC
Updated:
22 Sep 2007 at 03:59 UTC
Jump to comment: Most recent file
Comments
Comment #1
Malthus commentedSorry if I seemed to have hijacked this. I had coded a solution by the time I saw Karoly's update. This patch is for 4.6 rather than HEAD as I haven't grokked the new Forms API as yet. Hopefully it can help someone coding a solution for HEAD.
If the browser has javascript enabled the existing 'more choices' checkbox is replaced with a 'add choice' button. Clicking the button add one more form input for poll choices. If javascript isn't enabled or available the old UI remains and thus there should be few compatibility issues. I've tested in Ephiphany (linux), Firefox (linux&windows) and IE6 (windows).
Comment #2
Bèr Kessels commentedwhy not make this general, something like $form['type'] => 'replicate'
A form item that can be added to any form to replicate a wrapped part of a form Foo times.
the [Gimme 5 file fields] would then be a link that would:
* fire some JS to replicate the wrapped part 4 times (so we have 5 fields)
* in case of no JS it would link to example.com/the/page/ with a GET that will fire some PHP to replicate the part 5 times.
This is what I was working on for the files stuff, well, the GET part, I left out the ajaxy stuff.
Ber
Comment #3
Thox commentedBer, I very much like your proposal and it would solve my current dilema:
I don't like mixing javascript into PHP (see Malthus' patch), but in this case it actually makes the code a lotsimpler. To recreate the same effect in an external file is taking me a large amount of code and would either take some DOM trickery (duplicating an old choice) or some AJAX to request the HTML of the new choice. Note: I've now paused work on making a patch as my 40+ lines of JS seem pointless compared to the above patch.
A standard way of replicating controls would be very handy indeed - and would of course have a single external JS file for making it work in various places.
Comment #4
jonbob commentedBer++
I'd use this in the CCK field types if it were available.
Comment #5
magico commentedProbably we can close this one, because CCK is present in the HEAD.
Comment #6
magico commentedComment #7
bdragon commentedI believe FormsAPI 3 solves this, or at least makes it feasible.