User login

Modifying profile node embedded in registration form

Here's the dump of the form information for the profile node type embedded in the user registration form.

I can't get form_alter to apply to just this form-- if I use node-form it works, but it shrinks every other body text field also.

Form ID: user_register
Array
(
    [user_registration_help] => Array
        (
            [#value] =>
        )

    [account] => Array
        (
            [#type] => fieldset
            [#title] => Account information
            [name] => Array
                (
                    [#type] => textfield
                    [#title] => Full name
                    [#default_value] =>
                    [#maxlength] => 60
                    [#description] => Your full name.  Spaces are permitted, but punctuation is not.
                    [#required] => 1
                )

            [mail] => Array
                (
                    [#type] => textfield
                    [#title] => E-mail address
                    [#default_value] =>
                    [#maxlength] => 64
                    [#description] => A valid e-mail address. All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail.
                    [#required] => 1
                )

        )

    [profile] => Array
        (
            [#type] => fieldset
            [#title] => Profile
            [#collapsible] => 1
            [#weight] =>
            [form] => Array
                (
                    [#type] => subform
                    [#id] => profile_node_form
                    [#arguments] => Array
                        (
                            [0] => stdClass Object
                                (
                                    [uid] => 0
                                    [name] =>
                                    [type] => profile
                                )

                        )

                    [#subform_after_build] => Array
                        (
                            [0] => nodeprofile_integration_adapt_node_form
                        )

                )

        )

    [#attributes] => Array
        (
            [enctype] => multipart/form-data
        )

    [submit] => Array
        (
            [#type] => submit
            [#value] => Create new account
            [#weight] => 30
        )

    [#parameters] => Array
        (
            [0] => user_register
        )

    [#type] => form
    [#post] => Array
        (
        )

    [#programmed] =>
    [form_id] => Array
        (
            [#type] => hidden
            [#value] => user_register
            [#id] => edit-user-register
        )

    [#id] => user-register
    [#description] =>
    [#required] =>
    [#tree] =>
    [#parents] => Array
        (
        )

    [#method] => post
    [#action] => /eng/user/register
    [#validate] => Array
        (
            [user_register_validate] => Array
                (
                )

        )

    [#submit] => Array
        (
            [user_register_submit] => Array
                (
                )

        )

    [log] => Array
        (
            [#type] => hidden
        )

)
Form ID: profile_node_form
Array
(
    [#id] => node-form
    [nid] => Array
        (
            [#type] => value
            [#value] =>
        )

    [vid] => Array
        (
            [#type] => value
            [#value] =>
        )

    [uid] => Array
        (
            [#type] => value
            [#value] => 0
        )

    [created] => Array
        (
            [#type] => value
            [#value] =>
        )

    [type] => Array
        (
            [#type] => value
            [#value] => profile
        )

    [changed] => Array
        (
            [#type] => hidden
            [#default_value] =>
        )

    [title] => Array
        (
            [#type] => textfield
            [#title] => Name
            [#required] => 1
            [#default_value] =>
            [#weight] => -5
        )

    [body_filter] => Array
        (
            [body] => Array
                (
                    [#type] => textarea
                    [#title] => Comment or Statement of Intentions
                    [#default_value] =>
                    [#rows] => 20
                    [#required] =>
                )

            [format] => Array
                (
                    [1] => Array
                        (
                            [#type] => value
                            [#value] => 1
                            [#parents] => Array
                                (
                                    [0] => format
                                )

                        )

                    [format] => Array
                        (
                            [guidelines] => Array
                                (
                                    [#title] => Formatting guidelines
                                    [#value] =>
Web page addresses and e-mail addresses turn into links automatically.
Allowed HTML tags: [I removed the tags list from here to preserve the formatting of this page]
Lines and paragraphs break automatically.

                                )

                        )

                    [2] => Array
                        (
                            [#value] =>
More information about formatting options

                        )

                )

        )

    [#node] => stdClass Object
        (
            [uid] => 0
            [name] =>
            [type] => profile
            [comment] => 0
            [status] => 1
            [promote] =>
            [sticky] =>
            [revision] => 1
        )

    [log] => Array
        (
            [#type] => hidden
            [#title] => Log message
            [#rows] => 2
            [#weight] => 20
            [#description] => An explanation of the additions or updates being made to help other authors understand your motivations.
        )

    [author] => Array
        (
            [#type] => fieldset
            [#access] =>
            [#title] => Authoring information
            [#collapsible] => 1
            [#collapsed] => 1
            [#weight] => 20
            [name] => Array
                (
                    [#type] => textfield
                    [#title] => Authored by
                    [#maxlength] => 60
                    [#autocomplete_path] => user/autocomplete
                    [#default_value] =>
                    [#weight] => -1
                    [#description] => Leave blank for Visitor.
                )

            [date] => Array
                (
                    [#type] => textfield
                    [#title] => Authored on
                    [#maxlength] => 25
                    [#description] => Format: . Leave blank to use the time of form submission.
                )

        )

    [options] => Array
        (
            [#type] => fieldset
            [#access] =>
            [#title] => Publishing options
            [#collapsible] => 1
            [#collapsed] => 1
            [#weight] => 25
            [status] => Array
                (
                    [#type] => checkbox
                    [#title] => Published
                    [#default_value] => 1
                )

            [promote] => Array
                (
                    [#type] => checkbox
                    [#title] => Promoted to front page
                    [#default_value] =>
                )

            [sticky] => Array
                (
                    [#type] => checkbox
                    [#title] => Sticky at top of lists
                    [#default_value] =>
                )

            [revision] => Array
                (
                    [#type] => checkbox
                    [#title] => Create new revision
                    [#default_value] => 1
                )

        )

    [preview] => Array
        (
            [#type] => button
            [#value] => Preview
            [#weight] => 40
        )

    [submit] => Array
        (
            [#type] => submit
            [#value] => Submit
            [#weight] => 45
        )

    [#after_build] => Array
        (
            [0] => node_form_add_preview
            [1] => nodeprofile_integration_adapt_node_form
        )

    [#base] => node_form
    [#parameters] => Array
        (
            [0] => profile_node_form
            [1] => stdClass Object
                (
                    [uid] => 0
                    [name] =>
                    [type] => profile
                    [comment] => 0
                    [status] => 1
                    [promote] =>
                    [sticky] =>
                    [revision] => 1
                )

        )

    [#process] => Array
        (
            [subform_element_separate_data_prepare] => Array
                (
                )

        )

    [#pre_render] => Array
        (
            [0] => subform_element_separate_data
        )

    [#type] => form
    [#post] => Array
        (
        )

    [#programmed] =>
    [form_id] => Array
        (
            [#type] => hidden
            [#value] => profile_node_form
            [#id] => edit-profile-node-form
        )

    [#description] =>
    [#attributes] => Array
        (
        )

    [#required] =>
    [#tree] =>
    [#parents] => Array
        (
        )

    [#method] => post
    [#action] => /eng/user/register
    [#validate] => Array
        (
            [node_form_validate] => Array
                (
                )

        )

    [#submit] => Array
        (
            [node_form_submit] => Array
                (
                )

        )

    [comment_settings] => Array
        (
            [#type] => fieldset
            [#access] =>
            [#title] => Comment settings
            [#collapsible] => 1
            [#collapsed] => 1
            [#weight] => 30
            [comment] => Array
                (
                    [#type] => radios
                    [#parents] => Array
                        (
                            [0] => comment
                        )

                    [#default_value] => 0
                    [#options] => Array
                        (
                            [0] => Disabled
                            [1] => Read only
                            [2] => Read/Write
                        )

                )

        )

    [subscriptions] => Array
        (
            [subscriptions_currentstatus] => Array
                (
                    [#type] => value
                    [#value] => 1
                )

        )

    [menu] => Array
        (
            [#type] => fieldset
            [#title] => Menu settings
            [#access] =>
            [#collapsible] => 1
            [#collapsed] => 1
            [#tree] => 1
            [#weight] => 30
            [title] => Array
                (
                    [#type] => textfield
                    [#title] => Title
                    [#default_value] =>
                    [#description] => The name to display for this menu link.
                )

            [description] => Array
                (
                    [#type] => textfield
                    [#title] => Description
                    [#default_value] =>
                    [#description] => The description displayed when hovering over a menu item.
                )

            [pid] => Array
                (
                    [#type] => select
                    [#title] => Parent item
                    [#default_value] =>
                    [#options] => Array
                        (
                            [1] =>  Navigation
                            [3] => -- Compose tips (disabled)
                            [4] => -- Content (disabled)
                            [9] => ---- Create content (disabled)
                            [100] => ------ Action
                            [95] => ------ Action group
                            [79] => ------ FAQ
                            [67] => ------ Image
                            [21] => ------ Page
                            [96] => ------ Profile
                            [22] => ------ Story
                            [60] => ------ Usernode
                            [98] => -- Database queries
                            [89] => -- Directory
                            [55] => -- My subscriptions
                            [57] => -- My usernode (disabled)
                            [85] => -- Node locations
                            [76] => -- Profile wizard
                            [61] => -- Recent posts
                            [69] => -- Search (disabled)
                            [84] => -- User locations
                            [80] => -- FAQ
                            [5] => -- Administer
                            [8] => ---- Content management
                            [36] => ------ Categories
                            [15] => ------ Comments
                            [18] => ------ Content
                            [20] => ------ Content types
                            [82] => ------ Flagged items
                            [45] => ------ Node family
                            [19] => ------ Post settings
                            [31] => ------ RSS publishing
                            [66] => ------ Search content
                            [47] => ------ Translations
                            [11] => ---- Site building
                            [14] => ------ Blocks
                            [17] => ------ Menus
                            [25] => ------ Modules
                            [88] => ------ Panels
                            [24] => ------ Themes
                            [68] => ------ URL aliases
                            [58] => ------ Views
                            [52] => ---- Organic groups
                            [62] => ------ Organic groups configuration
                            [10] => ---- Site configuration
                            [23] => ------ Administration theme
                            [75] => ------ Captcha
                            [97] => ------ Checkall boxes
                            [34] => ------ Clean URLs
                            [32] => ------ Date and time
                            [99] => ------ Devel
                            [27] => ------ Error reporting
                            [29] => ------ File system
                            [72] => ------ File uploads
                            [46] => ------ Fivestar
                            [81] => ------ Flag content
                            [74] => ------ Form store
                            [78] => ------ Frequently Asked Questions Settings
                            [77] => ------ Generate installation profile
                            [83] => ------ GMap
                            [86] => ------ GMap Location
                            [65] => ------ Image
                            [30] => ------ Image toolkit
                            [16] => ------ Input formats
                            [64] => ------ Localization
                            [87] => ------ Location
                            [63] => ------ Multilingual system
                            [28] => ------ Performance
                            [70] => ------ Search settings
                            [26] => ------ Site information
                            [33] => ------ Site maintenance
                            [54] => ------ Subscriptions
                            [59] => ------ Voting API
                            [53] => ---- Registration role
                            [13] => ---- User management
                            [39] => ------ Access control
                            [41] => ------ Access rules
                            [48] => ------ Invite settings
                            [50] => ------ LoginToboggan
                            [40] => ------ Roles
                            [73] => ------ Search users
                            [37] => ------ Users
                            [38] => ------ User settings
                            [12] => ---- Logs
                            [42] => ------ Recent log entries
                            [44] => ------ Top 'access denied' errors
                            [43] => ------ Top 'page not found' errors
                            [71] => ------ Top search phrases
                            [56] => ------ Available updates
                            [35] => ------ Status report
                            [7] => ---- Help
                            [6] => -- Log out
                            [2] =>  Primary links
                            [90] => -- Home
                            [93] => -- Why a 2008 Day of Action?
                            [94] => -- In Your Region
                            [92] => -- News
                            [49] => -- Invite
                            [91] => -- Login
                        )

                )

            [path] => Array
                (
                    [#type] => hidden
                    [#value] =>
                )

            [weight] => Array
                (
                    [#type] => weight
                    [#title] => Weight
                    [#default_value] =>
                    [#delta] => 10
                    [#description] => Optional. In the menu, the heavier items will sink and the lighter items will be positioned nearer the top.
                )

            [mid] => Array
                (
                    [#type] => hidden
                    [#value] => 0
                )

            [type] => Array
                (
                    [#type] => hidden
                    [#value] => 86
                )

        )

    [path] => Array
        (
            [#type] => fieldset
            [#title] => URL path settings
            [#collapsible] => 1
            [#collapsed] => 1
            [#access] =>
            [#weight] => 30
            [path] => Array
                (
                    [#type] => textfield
                    [#default_value] =>
                    [#maxlength] => 250
                    [#collapsible] => 1
                    [#collapsed] => 1
                    [#description] => Optionally specify an alternative URL by which this node can be accessed. For example, type "about" when writing an about page. Use a relative path and don't add a trailing slash or the URL alias won't work.
                )

        )

    [taxonomy] => Array
        (
            [tags] => Array
                (
                    [1] => Array
                        (
                            [#type] => textfield
                            [#title] => Organization
                            [#description] => Name the organization or organizations with which you affiliate.  If you think someone may have entered your organization already, type a few letters and wait for autocomplete to get an exact match.
                            [#required] => 0
                            [#default_value] =>
                            [#autocomplete_path] => taxonomy/autocomplete/1
                            [#weight] => -6
                            [#maxlength] => 255
                        )

                )

            [#weight] => -3
            [#tree] => 1
        )

)

The solution I used was to theme the form, which frankly rocks. In template.php

Wish I'd started doing this a while ago (I suppose I should be using the theme name rather than "theme_")

Resolution

function theme_profile_node_form($form) {
  // this is all I wanted to do.
  $form['body_filter']['body']['#rows'] = 5;
// drupal_set_message('<pre>' . print_r($form, TRUE) . '</pre>');

  $output = "\n<div class=\"node-form\">\n";
  // Admin form fields and submit buttons must be rendered first, because
  // they need to go to the bottom of the form, and so should not be part of
  // the catch-all call to drupal_render().
  $admin = '';
  if (isset($form['author'])) {
    $admin .= "    <div class=\"authored\">\n";
    $admin .= drupal_render($form['author']);
    $admin .= "    </div>\n";
  }
  if (isset($form['options'])) {
    $admin .= "    <div class=\"options\">\n";
    $admin .= drupal_render($form['options']);
    $admin .= "    </div>\n";
  }
  $buttons = drupal_render($form['preview']);
  $buttons .= drupal_render($form['submit']);
  $buttons .= isset($form['delete']) ? drupal_render($form['delete']) : '';

  // Everything else gets rendered here, and is displayed before the admin form
  // field and the submit buttons.
  $output .= "  <div class=\"standard\">\n";
  $output .= drupal_render($form);
  $output .= "  </div>\n";

  if (!empty($admin)) {
    $output .= "  <div class=\"admin\">\n";
    $output .= $admin;
    $output .= "  </div>\n";
  }
  $output .= $buttons;
  $output .= "</div>\n";

  return $output;
}

Searched words: 
form_alter subform form within a form theme profile as node user registration form

Comments

What code did you set in your .module?

Hi,
I am trying to get openresort to upgrade from D5 to D6, and having problems with theming, see: http://drupal.org/node/290622#comment-2430344
I think it has also to do with theming..do I need to set: theme_node_business in template.php, and how do I call this then in my business.module?

Thanks a lot in advance for your reply!

Greetings, Martijn

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Syntax highlight code surrounded by the {syntaxhighlighter SPEC}...{/syntaxhighlighter} tags, where SPEC is a Syntaxhighlighter options string or "class="OPTIONS" title="the title".
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.