Adrian's idea, Thox already volunteered to do it if someone opens an issue. Here you come.

CommentFileSizeAuthor
#1 poll_js_patch.txt2.67 KBMalthus

Comments

Malthus’s picture

Version: x.y.z » 4.6.3
StatusFileSize
new2.67 KB

Sorry 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).

Bèr Kessels’s picture

why 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.

title
[          ]
description
[          |
|          ]
----- wrapped in a div, "fileStuff" --
file
[          ] [browse]
[X] fooBar
[ ] anohterBar

[Gimme 5 file fields]
------end wrap "fileStuff" ---------------

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

Thox’s picture

Ber, 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.

jonbob’s picture

Ber++

I'd use this in the CCK field types if it were available.

magico’s picture

Probably we can close this one, because CCK is present in the HEAD.

magico’s picture

Version: 4.6.3 » x.y.z
bdragon’s picture

Version: x.y.z » 6.x-dev
Status: Active » Closed (duplicate)

I believe FormsAPI 3 solves this, or at least makes it feasible.