tags:

views:

532

answers:

1

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] => 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
        )
+2  A: 

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].

abhaga
drupal_set_message(print_r($node,TRUE)) in the .tpl doesn't output anything. Nor does $node->field_sr_status[0]['view'] where field_sr_status is the name of my field.
cinqoTimo
Sorry. Misunderstood your question. Updated the answer. May be this would help.
abhaga
I'll throw you a +1...you solved a problem that was driving me nuts as well ^_^
espais