0

I have a number of services on my site and I want them to all direct to the contact form. Now, this is where it gets tricky- I want the subject to be a dropdown selection of all services provided and, if possible [bonus], based on the link clicked (GET/POST).

Alternatively: I would also be open to a contact-form jquery popup modal box that I could tailor for specific services.

Any help is greatly appreciated and I thank you in advance.

1 Answer 1

1

You can try hook_node_view() to pre-select default value of webform component on the base of referer.

function yourmodule_node_view($node, $view_mode){
    if($node->nid == [nid of webform]){
            global $base_path;
            $referer = $_SERVER["HTTP_REFERER"];
            $start = strpos($referer, $base_path) + strlen($base_path);
            $ref_local_path = substr($referer, $start);
            switch($ref_local_path){
                    case 'service_1_path':
                            $node->content['webform']['#form']['submitted']['<component_name>']['#default_value'] = 'option_1';
                    break;
                    case 'service_2_path':
                            $node->content['webform']['#form']['submitted']['<component_name>']['#default_value'] = 'option_2';
                    break;
            }
    }
...

If you are looking to do it via JS/JQuery that is another solution.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.