I will write up a handbook page on setting your Hierarcial Select for Taxonomy to default if you can solve my problem!
What I had was in my form-xxx.tpl.php
$form['taxonomy'][16]['#value']=array(0 => arg(3));
But this does not work with Hierarcial Select. It works for the default select but not when hierarcial select is applied. Any Suggestions?
Mike
Comments
Comment #1
wim leersYou shouldn't use #value, it's wrong. Use #default_value instead.
Comment #2
MGParisi commentedI have tried #default and #value. I just tried #default_value. I tried it in an array and outside of an array.
$form['taxonomy'][24]['#default_value']=arg(3);I have a feeling its because Im setting this in the node-form-showandtell.tpl.php and you already have the javascript all set before you enter this stage. Therefor I would have to put it earlier in the code. This is an assumption, I dont know when to put this. I might over-ride the theme function (if there is one). Any suggestions?
Comment #3
wim leersThat's indeed absolutely completely wrong. Use hook_form_alter() to set it.
Comment #4
MGParisi commentedI have PDD and am looking at the API, I am triing to figure this out. I just don't understand it! I just realized what we need in documentation! EXAMPLES!
This ofcourse is not working, but I am one step I found the node_ID, I had tried the above plus combination of arrays and non-arrays... Im attempting to learn and do it myself, I am just having a really tough time. I found
http://groups.drupal.org/node/4308
Which is helpfull as I learn about how to use the hook_form_alter.
Comment #5
MGParisi commentedWim Im lost, I been beating my head on this one since your last post. I cant seem to get $node to be in the right state, or Im not calling it in the right place. I got my PDD and everything. Ive tried IRC and the above resources... at this time I dont understand this API and how it applies to your module one bit... Do I put the whole node in... can I put it in my $contenttype-form.tpl.php! What do I insert as the $node... Everything I have tried doesn't work, and hook_form_alter is only discussed in a module development sense and not a theme development sense.
Comment #6
wim leersEhm, well, you should not set default values in a "theme sense". It's the wrong place. If you don't want to learn how to use it, fine, but please don't keep keep asking in my issue queue.
Comment #7
wim leersComment #8
MGParisi commentedIm sorry, I thought I came across as BEGGING for help because I cant seem to learn it... I want to develop modules and contribute. I want to become better with Drupal at all levels... I spend a TON of time helping others in IRC, and I learn allot doing it.. but I am not getting any answers or solutions to this question. I even am on the Doc Team to help fix documents as I learn more about the system. Im doing everything short of paying someone to show me how, and I cant afford that.
I found this code... http://drupalbin.com/64
From what I get, I have to create a module?!?
I'm doing everything I can to learn it... I'm off to create a dev box and a module... I don't even know if that's what I'm suppose to do, but I am going to try! Its the only advice anyone has given me. I guess I could build the hook_form_alter using the above code in a custom module. I am not to sure how to hook this into your module or how to hook this into the specific cck type, but then again, I am not sure of anything...
Heck, Ive been through YouTube (DrupalDojo is down) looking for tutorials on how to do it. Groups, API's, Forums, Handbooks, Blogs... Ive spent days trying to figure it out. I'm missing SOMETHING and I don't even know what it is to ask! I thought I could do this in the theme file, but it appears I cant (I don't know, no one has given me any answers), I thought I could make a function in template.php (again, I dont know, no one has told me otherwise). In fact no one has told me anything about hook_form_alter... and all references to it is in module development. So it MUST be a module only function, Right?
I don't know, cant get any answers... no path to pursue... lost... confused... frustrated
I am BEGGING for direction... just help me, point me to the right direction and approach... ANYTHING!
Mike
Comment #9
MGParisi commented// To Wim Leers is this acceptable Hand Book Page?
Handbook Page: Setting Hierarchial_select by Argument for Drupal 5.X
To set the Hierarchial_select by argument is simple. To do so, simply create a module with a .info and .module file. In the .module file you must change the $form array '#default_value' to an array with the values you want. You must first find your $form_id. You can do this by following the documentation here http://api.drupal.org/api/function/hook_form_alter/5! In the bellow code replace the "yourformid" with the appropriate form_id. Next check your arg for appropriately set taxonomy numbers. Without doing this, it maybe possible for a user to put in a non valid taxonomy number not associated with the document type.
Enable your module and enter in the form path, then add the taxonomy term ID as arg(3). This should set the default value of the select to be what you want.
Comment #10
wim leers