Hi there,

I'm using the profile.module to generate a more detailed user registration form, and it works pretty well. However, I would like to be able to set field types and attributes. For example, I'm using a single line entry field to allow the user to input their phone number. I would like to be able to set the field type for that particular entry field to be "numeric". Other suggestions would be letters only, or numbers in a specific range, or even to be able to set your own regex. I'd also like to be able to limit the number of characters entered in the text fields.

I'd also like to be able to use radio buttons but don't see how I can do that. I can work around this for the moment by using a list selection. The only other thing I think might be missing is the ability to add a list selection where you can select multiple items.

Cheers,
Stella

CommentFileSizeAuthor
#4 drupal_profile.2.patch24.09 KBAlan D.
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

killes@www.drop.org’s picture

Version: 4.7.3 » x.y.z

new features go into devel version.

lilou’s picture

Version: x.y.z » 7.x-dev

This feature request is it still valid ?

Alan D.’s picture

As a fallback if Migrate profile module data to field API doesn't get in. Guessing this is too late to get reviewed though.

This is a minimalist approach to extending the profile module without hooking into fields. It is a port of a Drupal 6 profile hack.

It uses the current profile field types and one new taxonomy field. The taxonomy field is saved as a serialized value, so no new db tables are required.

It moves profile field definitions to a simple hook_profile_fields().

Each defined profile field can have three configurable callbacks:

  1. Configuration options form (optional)
  2. User input form (required), defaults to "profile_field_{$key}_form"
  3. User view form (required), defaults to "profile_field_{$key}_view"

Two load / save callbacks can be specified. These are run through the data on load / before saving, enabling better data handling if required. For the date and taxonomy fields, this is simply unserialize and serialize calls for date and taxonomy.

For example, the taxonomy field is defined as:

<?php
function profile_profile_fields() {
  $fields = array();
  // ...
  if (module_exists('taxonomy')) {
    $fields['taxonomy'] = array(
      'title' => t('taxonomy'),
      'description' => '',
      'save callback' => 'serialize',
      'load callback' => 'unserialize',
      'options callback' => 'profile_field_taxonomy_options'
    );
  }
  return $fields;
}

?>
Alan D.’s picture

FileSize
24.09 KB

The preview killed the attachment ;\

Alan D.’s picture

Status: Active » Closed (duplicate)