hi there -
I'm an experienced LAMP Developer in a new job where most of my development will now be done using Drupal. I am a Drupal newbie. While I have picked up the book Pro Drupal Development, I am still having a problem figuring out how to do something that I feel is so simple, yet Drupal makes it impossible (at least to the newbie).
I've made several posts on the Post-Installation forum and have tried the #drupal-support IRC channel to no avail. So I guesss if I need to pay for some consulting it's what I gotta do. Here's the problem:
I need to be able to validate certain CCK fields of a node when content is being added or edited. There is one section called "Exclusivity" which contains a CCK checkbox and 3 other CCK fields. The other 3 CCK fields are dependent on whether this checkbox is checked or not. If it is checked, then the user is required to complete the following 3 CCK fields:
Client (CCK checkboxes - multiple values. Uses PHP Code to grab clients from DB)
StartDate (CCK Date field)
EndDate (CCK End Field)
MY CONFUSION
I've tried to use hook_form_alter() and hook_nodeapi() and hook_validate() to no avail, mostly due to the way CCK names its fields. It seems to put the fields and values in multidimentional arrays. So as I try to validate the fields, I can't figure out how to refer to them in the $form and/or $form_values arrays as Drupal seems to see them differently then what the HTML source says.
Has anyone accomplished something similar in the past? Again if I were not using Drupal I'd have this done in 15 minutes, but because of Drupal I've already lost a weekend trying to figure this out. I have googled up the wazoo and the documentation on validating CCK fields is scarce or just plain incorrect.
Anyways, any help would be greatly appreciated. Let me know how much you'd think this would cost for some help.
thanks!
Comments
Javascript
You can use Jquery to validate your fields. So, you can unset the fields and when you click the checkbox you show them with javascript. This is quick solution and works.
I can do it if you or just ask me for more help !!
good luck and sorry for my english!
----
Diego Miola
http://diegomiola.dostypos.com.ar
"I've tried to use
"I've tried to use hook_form_alter() and hook_nodeapi() and hook_validate() to no avail, mostly due to the way CCK names its fields. It seems to put the fields and values in multidimentional arrays. So as I try to validate the fields, I can't figure out how to refer to them in the $form and/or $form_value"
I have the same problem - it's driving me nuts :)
I used hook_nodeapi() and have no idea how the CCK fields are added to the node object ?!?! if my field is time1 how do I access it???
is it $node->time1, $node->field_time1 ? I looked in the database (for table node_field) and database calls it field_time1 but it still doesn't work.
If there's anyone who can enlighten me/us PLEASE come forward :)
briantully - see this
briantully - see this http://drupal.org/node/134289. Pay attention to running print_r($node) so that the $node object can tell you what it consists of. If you have other questions reply here and I'll try to answer.
hook_nodeapi() worked like a charm for me :)