开发者

Set a Default Value For Drupal Profile Multiselect Field

I'm using Drupal core profile module, with Profile checkboxes to add two custom fields to the user profile.

I need to set a default value for those two fields, for instance, make the first option checked by default. How can this be done? I'm quite newbie at Drupal development, but any guidance will be appreciated.

I'm using Druapl 6.22, Profile 6.22, & Profile Checkboxes 6.x-1.2

I searched, & get this:

<?php
function my_module_form_alter(&$form, &$form_state, $form_id) {
    if($form_id == 'user_profile_form') {
        if(arg(0) == 'user' && arg(1)) {
            $user = user_load(arg(1));
                    //Something wrong is here!!!
            $form['test']['profile_test'][1]['#default_value'] = TRUE; 
        }
    }
}
开发者_如何学C

This is not working. I don't know how to get the correct field. All I need is to set a default value for the first option in this multiple choice check-box. How??


You can alter that form (for check boxes) in a custom module using form api. Try to alter form using your_module_form_alter() in your custom module and set '#default_value' = true for any of your check boxes. Assuming you know how to create custom modules.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜