2

I want to write a module that creates a content type with a title and one or more textfields. I'm having a very hard time simplifying the roles of each hook function call in the documentation of the node_examples module.

Right now I'm trying to figure out what the next function should be and what it will do with the form data. So far I've gotten the content type and the forms to show up in the add content section of my site but when I save the "votable" content none of the form data is stored, just a blank piece of content with content type "votable". Could someone point me towards the next step?

function votable_form($node, &$form_state) {
    $type = node_type_get_type($node);
    $form = array();       
    $form['votable_title'] = array(
        '#type' => 'textfield',
        '#title' => check_plain($type->title_label),
        '#default_value' => !empty($node->title) ? $node->title : '',
        '#required' => TRUE,
        '#weight' => -5,
    );  

    $form['votable_results'] = array(
        '#type' => 'textarea',
        '#title' => t('Results'),
    );

    return $form;
}


 function votable_node_info() {
    return array(
        'votable' => array(
            'name' => t('Contestant'),
            'base' => 'votable',
            'module' => 'votable',
            'description' => t("Select this content type to create a Contestent Page"),
            'help' => 'add content',
            'title_label' => t('Contestant Name'),
            'has_body' => FALSE,
        ),
    );
 }
1

Flex Slider creates a content type for a slider image and a view to make the slider itself, so you could look at that for an example module.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.