Hey guys,
I have looked everywhere for an explanation or example of how to add functionality such as this, but have had no such luck! So maybe you can help...
What i am trying to do in a nutshell, is to add an already defined image upload field (using cck and imagefield modules) and then display this form element within my created node form via an AHAH callback.
So for example, i have a radio button set, where the user can select one of the options to 'add image to page', and what i want to do is allow them to add their image by generating the image upload field on the fly (using AHAH).
So i can either do this i guess by creating my own image upload field. Although i'm thinking this might generate a lot more work? and it seems silly to me to write all this code, when the cck module can kind of do it for you, really easily and quickly. Plus it has a lot of features like database configuration, displaying the currently uploaded image to a node on the edit node form really nicely etc.
I tried looking into creating a cck form element programmatically, but it seems unclear to me on how you create your actual form elements themselves...i have seen tutorials on how to create your own cck types (for on the manage fields menu when editing your content type) but that isn;t really what i want. I haven't seen any examples anywhere on how to write the php code to create a cck field in your node_form().
My question is, does anyone know of a way to either create cck fields in your node_form()?
Or if this can't really be done, can you create your field using 'manage fields' page on your content type, and then control how this is displayed on your form using some javascript/ahah callback?
If anyone could give me some guidance or direction on this that would be great! i'm getting really lost with this one, and want to figure out the best of way of achieving this!
thanks in advance
Craig
Comments
ahah controled fields
Hi,
I'm actually looking for the same answer. At the moment my best guess is that all the controlled fields must be there when the form loads, but they can be in a "disabled" (e.g. display:none) then the ahah call would first get the current form state, modify it accordingly to show (or hide) the controlled fields.
Another possibility I'm looking at is to use the "javascript triggers" for cck. Then you can control an action that does the hiding/unhidding, but I'm failing to get some documentation on how actually use it, and I haven't tried to code it yet.
cck javascript control...
Hey Miguel,
I was actually thinking of resorting to javascript, doing a show/hide type of thing. But i really didn't want to do it this way!
Anyone else out there know if programmatically creating cck fields is possible? Or is there another possible way of performing this functionality?
cheers
Craig
See this might help AHAH
This might help http://www.heididev.com/using-ahah-cck-field
Heshan Wanigasooriya
Github