开发者

Drupal Imagfield/Filefield in custom form

开发者 https://www.devze.com 2022-12-22 04:50 出处:网络
i have created a module with this among others this function in it: <?php function ils_ladda_upp_form() {

i have created a module with this among others this function in it:

<?php
function ils_ladda_upp_form() {
    $form['upload'] = array(
        '#method' => 'post',
        '#attributes' => array(
            'enctype' => 'multipart/form-data',
        )
    );
    $form['upload']['album_name'] = array(
        '#type' => 'textfield',
        '#title' => t('Albumnamn'),
        '#required' => 1
    );
    $form['upload']['album_location'] = array(
        '#type' => 'textfield',
        '#title' => t('Plats'),
    );
    $form['upload']['album_date'] = array(
        '#type' => 'date',
        '#title' => t('Datum'),
        '#required' => 1,
        '#suffix' => '(då bilderna togs)'
    );
    $form['upload']['album_description'] = array(
        '#type' => 'textarea',
        '#title' => t('Beskrivning'),
        '#resizable' => false,
    );
    $form['upload']['school'] = array(
        '#type' => 'hierarchical_select',
        '#title' => t('Skola & Klass'),
        '#size' => 1,
        '#required' => 1,
        '#config' => array(
            'module' => 'hs_taxonomy',
            'params' => array(
            'vid' => 1,
            ),
            'save_lineage'    => 0,
            'enforce_deepest' => 0,
            'entity_count'    => 0,
            'require_entity'  => 0,
            'resizable'       => 0,
            'level_labels' => array(
            'status' => 0,
            'labels' => array(
                0 => t('Main category'),
                1 => t('Subcategory'),
                2 => t('Third level category'),
          开发者_开发问答  ),
        ),
            'dropbox' => array(
            'status'   => 0,
            'title'    => t('All selections'),
            'limit'    => 0,
            'reset_hs' => 1,
        ),
            'editability' => array(
            'status'           => 0,
            'item_types'       => array(),
            'allowed_levels'   => array(
            0 => 0,
            1 => 0,
            2 => 1,
            ),
            'allow_new_levels' => 0,
            'max_levels'       => 3,
        ),
            # These settings cannot be configured through the UI: they can only be
            # overridden through code.
            'animation_delay'    => 400,
            'special_items'      => array(),
            'render_flat_select' => 0,
            'path'               => 'hierarchical_select_json',
        ),
        #'#default_value' => '83',
    );
    $form['upload']['file'] = array(
        '#type' => 'file',
        '#title' => t('Bild'),
    );
    $form['upload']['name'] = array(
        '#type' => 'textfield',
        '#required' => true,
        '#title' => t('Ditt namn')
    );
    $form['upload']['submit'] = array('#type' => 'submit', '#value' => t('Ladda upp'));
    return $form['upload'];
}
?>

Is it possible to insert a CCK Filefield/imagefield in the form? If so, how do i do it?

Drupal v. 6.15

Regards,

Joar


Like this? http://sysadminsjourney.com/content/2010/01/26/display-cck-filefield-or-imagefield-upload-widget-your-own-custom-form


You should use:

D6: http://drupal.org/project/upload_element upload_element type

D7: managed_file type

Instead of CCK filefield, it is almost the same (ajax, ahah upload) & you can implement it without hacking CCK

0

精彩评论

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