开发者

Theming a node/add form in Drupal 6

开发者 https://www.devze.com 2022-12-17 17:56 出处:网络
I have a statement in my template.php file that directs to a custom node-myccktype.tpl.php. I\'ve added some DIV\'s so that I can have a two column node/add form, but now I\'m trying to find print my

I have a statement in my template.php file that directs to a custom node-myccktype.tpl.php. I've added some DIV's so that I can have a two column node/add form, but now I'm trying to find print my fields, but can't seem to get it.

I'm basically using something like this:

<?php print form_render($form['field_sr_minutes']); ?>

which I came across on a Drupal Blog, but I get call to undefined function "form_render"

I am using the var_dump to get the the array below, how can I print my node title(subject) field without printing everything else? This way I can put each form field in the column I want Instead of the standard vertical drupal form.

Array
(
    [0] => Array
        (
            [#type] => textfield
            [#title] => Subject
            [#required] => 1
            [#default_value] => 
            [#maxlength] => 255
            [#weight] => -5
            [#post] => Array
                (
                )

            [#programmed] => 
            [#tree] => 
            [#parents] => Array
                (
                    [0] => title
                )

            [#array_parents] => Array
                (
                    [0开发者_JAVA技巧] => title
                )

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

            [#input] => 1
            [#size] => 60
            [#autocomplete_path] => 
            [#process] => Array
                (
                    [0] => form_expand_ahah
                )

            [#name] => title
            [#id] => edit-title
            [#value] => 
            [#defaults_loaded] => 1
            [#sorted] => 1
        )


Sorry. Because of your .tpl file name I thought that you were trying to theme a node view. For forms, the right function is not form_render but drupal_render. You can basically write things like echo drupal_render($form['field_sr_minutes']) . In the very end, remember to do a drupal_render($form) to render all the remaining things which you have not rendered by hand. This will be required to have the form working correctly.

Old Answer

The node.tpl.php and other content type specific .tpl.php get passed the full node object in $node. Try doing a drupal_set_message(print_r($node,TRUE)) on top of your tpl file. From that you can figure out the exact path of the values you need to print.

For example, title of the node will be available in $node->title. However you should be careful to always use check_plain if you are going to print user submitted values. For CCK fields, you can find the already filtered values in $node-><field name>[0][view].

0

精彩评论

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