0

can it be possible to alter the exposed form , make field hidden and accept it through node form field.

for example

Both node and views exposed filter will have the common date field and this view is shown on node/add pages. Instead of showing exposed filter field (date field) I

want to pass node form's field as filter to views which is in block.This will inform user what has been created on that date and prevent duplication.

Is this possible with just hook_form_alter ?

1 Answer 1

1

Yes its possible we do it like this

 function module_name_form_alter(&$form, &$form_state, $form_id) {
    if ($form_id == "views_exposed_form"){  
        $formId1 = "views-exposed-form-view-name-block-2";
        if($form_state['view']->name == "view_name"){
            if($form['#id'] == formId1){
                $form_state['input']['field_name'] = $value_field_name;     //set value         
                $form['field_field_name']['#default_value'] = $value;//set default value
                $form['field_field_name']['#value'] = $value;//set the field value
            }
        }
    }
}

Your Answer

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

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