Pedro Posada | Retrieve cck node form array

Retrieve cck node form array

Posted on December 13, 2010 - 3:48pm
<< 2 of 54 >>

The code bellow is to be used in any module. It requires cck module to be installed. The advantage of this code is that it allows you to use labels and field definitions done through the cck ui. It allowed me to build a custom form based in the fields previously defined, it saves time and keeps your custom form consistent with the content type form.

<?php

global $user;
$type = 'my_content_type';
$node = array(
     
'uid' => $user->uid,
     
'name' => (isset($user->name) ? $user->name : ''),
     
'type' => $type,
     
'language' => '',
    );
$form_state = array();
$form = node_form($form_state, $node);
drupal_prepare_form($type . '_node_form', $form, $form_state);
print
'<pre>'.check_plain(print_r(element_children($form), true)).'</pre>';

?>

Submitted by Lesauf (not verified) on January 23, 2011 - 4:27am.

Thanks, but this not worked for me. I had an error with node_form().
I found a better solution at http://drupal.org/node/357895#comment-1311764.

Hum, your captcha are too small...

Submitted by pedro on November 15, 2011 - 2:15pm.

Yes, your solution seems better.

Thanks

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Copy the characters (respecting upper/lower case) from the image.