function profile2_generate_form in Profile 2 7
Same name and namespace in other branches
- 7.2 profile2.devel.inc \profile2_generate_form()
Form that allows to generate a user profiles with dummy data.
1 string reference to 'profile2_generate_form'
- profile2_menu in ./
profile2.module - Implements hook_menu().
File
- ./
profile2.devel.inc, line 12 - Contains integration with Devel generate modules. Provides possibility to generate dummy profiles for users.
Code
function profile2_generate_form($form, &$form_state) {
// Generate a list with available profile types.
$profile_types = profile2_get_types();
foreach ($profile_types as $id => $type) {
$profile_types[$id] = $type->label;
}
$form['profile2_types'] = array(
'#type' => 'checkboxes',
'#title' => t('Generate profiles of the following types'),
'#description' => t('Select profile type(s) to create profile. If no types are selected, profiles of all types will be generated.'),
'#options' => $profile_types,
);
$roles_list = user_roles(TRUE);
// Don't show authorized role.
unset($roles_list[DRUPAL_AUTHENTICATED_RID]);
$form['profile2_roles'] = array(
'#type' => 'checkboxes',
'#title' => t('Generate profiles for following user roles'),
'#options' => $roles_list,
);
$form['profile2_generate_limit'] = array(
'#type' => 'textfield',
'#title' => t('Maximum number of profiles per type'),
'#element_validate' => array(
'element_validate_integer_positive',
),
'#default_value' => 50,
'#size' => 10,
);
$form['profile2_delete'] = array(
'#type' => 'checkbox',
'#title' => t('Delete existing profiles'),
);
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Generate'),
);
return $form;
}