0

I am going to alter the form of add content type form and for that I used the hook_form_FORM_ID_alter()

Here is my code which implement in the module file, but it is not working.

function hc_listings_menu()
{
    $items = array();
    $items['node/add/home-care-popular-search-region']=array(
        'title' => 'Create Home Care Popular Search Region',
        'page callback' => 'drupal_get_form',
        'page arguments'=> array('home_care_popular_search_region_node_form',''),
        'type'=>MENU_NORMAL_ITEM,
    );
    return $items;
}
function hc_listing_home_care_popular_search_region_node_form_alter(&$form, &$form_state, $form_id)                                 
{

    $state_list=['ffff','gggg'];
    $region_list=['1','2','3','4'];
    $form['home_care_popular_search_region']=array(
        '#type' => 'textfield',
        '#default_value' => '',
        '#title' => t('Homeeee Care Popular Search Region'),
        '#description' => t('Home Care Popular Search Region'),
        '#required' => TRUE,

    );
    $form['hc_popular_state']=array(
        '#type' => 'select',
        '#default_value' => $state_list,
        '#title' => t('Popular State'),
        '#description' => t('Home Care Popular State'),
        '#required' => TRUE,
    );
    $form['hc_popular_regions']=array(
        '#type' => 'select',
        '#default_value' => $region_list,
        '#title' => t('Popular Search Region'),
        '#description' => t('Home Care Popular Search Region'),
        '#required' => TRUE,
    );

}

Note: content type is => home_care_popular_search_region

module is => hc_listing

Should I have to remove the details in hook_menu regarding the altering?

2 Answers 2

0

First, You need to find out the correct form id for this form and then you can use,

hook_form_FORM_ID_alter there.

Thanks

0

Remove the hook_menu from the module because there are not need to add this menu item.

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.