Closed (fixed)
Project:
Shortcode
Version:
7.x-2.0-alpha5
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
30 Nov 2012 at 11:15 UTC
Updated:
19 Apr 2015 at 08:24 UTC
Jump to comment: Most recent
Comments
Comment #1
denes.szabo commentedCan you show to me your code?
Comment #2
BarisW commentedSure:
Comment #3
jurriaanroelofs commentedIf you use states like in the sc_basic module you can have multiple shortcodes in one form but only show form elements related to 1 specific shortcode.
See the demo to get an idea of how this works:
http://youtu.be/IvA3SYPmqVo?t=13s
The key is to make any shortcode attribute only visible when its corresponding selectbox option is selected. This is accomplished with the form states:
More examples: http://drupalcode.org/project/sc_basic.git/blob/refs/heads/7.x-1.x:/sc_b...
Comment #4
BarisW commentedTried, but doesn't work as expected. The problem is that each form can have fields with the same title (eg a Title field).
Using #states only hides elements but the form still contains all these elements.
Comment #5
denes.szabo commentedMoved to the shortcode_wysiwyg project.
Comment #6
karens commentedConfirming that the states system does not handle this correctly. I just created a patch to populate the attributes that come with this module, which makes it clear that it does not work. So I changed it to prefix each attribute with the shortcode name so each is unique, which will work correctly to show/hide elements.
See https://www.drupal.org/node/2312353.
The only other way to solve the problem, as noted above, would be to change the system completely and ajax load forms based on the shortcode selection. That would be a lot more work, so I assume this other solution makes more sense.
Comment #7
denes.szabo commentedKarenS patches applied to the latest dev version.