Hi folks,
I'd be grateful if some wiser heads than mine could help with the strange problem. Am writing my first custom validation module to custom validate dates on 2 seperate forms created with CCK, sample code below:
<?php
function bookings_validate_form_alter(&$form, &$form_state, $form_id){
if($form_id == 'event1_node_form') {
// Validate event1
$form['#validate'][] = 'custom_event1_validate';
} elseif { ($form_id == 'event2_node_form') {
// Validate event2
$form['#validate'][] = 'custom_event2_validate';
}
}
function custom_event1_validate($form,&$form_state){
// Go validate event1 - runs consistently
}
function custom_event2_validate($form,&$form_state){
// Go validate event2 - fails intermittently
}
Event 1 validates 100% of the time without error. Event 2 falls over just before:
$form['#validate'][] = 'custom_event2_validate';
If I restart Apache I can get it to call custom_event2_validate consistently once, but after that it will only call the function maybe 50% of the time :-0
Have checked:
1. Proxy settings on browser (Disabled)
2. PHP error logs (nothing untoward)
3. Disabled all unnecessary modules (CCK and Views still in use)
4. Xdebug disabled
5. Liberally peppered code with echo statements to see where it fails.
Am I missing something really obvious here? Or can I just not see the wood for the trees?
Tested with FF / Chrome on Ubuntu 10.10. Server is Ubuntu Server 10.10 patched to latest revisions.
Many thanks in advance.
Comments
you have an extra {
If you pasted your code, then it is wrong, you have an extra { brace on this line
Shoud be
Thanks justageek, and sorry
Thanks justageek, and sorry about that - not sure how that slipped in, too much time in front of computer today I guess.
Is what is on the server, still won't run consistently ....
what are the symptoms?
When you say it doesn't run consistently, how do you know? What are the symptoms? Can you post the validation code itself?
Solved!!
Morning Justageek,
Thanks again for all your help and quick response. I was really pulling my hair out on this.
Came in this morning and the call to custom_event1_validate started failing as well and not running. Now I KNOW the underlying code is fine, it has been tested and run for weeks now without any problems .....
It transpires that we have a transparent proxy on the network, which intercepts all port 80 traffic. Looks like it was causing the code to intermittently break / not load / timeout. Once I used a different proxy event1 and event2 run consistently with no modifications to the code.
Suppose it serves me right in a way for trying to modify modules on a remote test server rather than on a development environment on my on PC, but we are close to go live and I wanted to test the server throughly ;-)
How did I know it was not firing? Added the following code and when the "Call EV2" and "custom_event2_validate" javascript alerts didn't fire, know something was up. Also, the page was validated OK with no obvious errors that the validation code should have picked up and no error messages were generated.
Crude I know, but I still need to sort out my quickstart and netbeans environment properly ....