Drupal主题使用tpl文件

时间:2017-07-31 09:18:24

标签: php drupal drupal-7

如何以Drupal 7中每行有2个字段的方式显示表单的字段?我想使用tpl.php文件而不是直接通过CSS来实现。有人可以帮忙吗?

下面我提供了表单的基本代码。请检查并告知是否还需要其他任何东西。

  $items['example/mfrp']=array(
        'title'=>'Example Form',
        'dsecription'=>'My first Real Time Project',
        'page callback'=>'drupal_get_form',
        'page arguments'=>array('mfrp_form'),
        'access callback'=>TRUE,
    );



 function mfrp_form($form,&$form_state){
    $form['name']=array(
        '#title'=>t("University Name"),
        '#type'=>'textfield',
        //'#value'=> t("Enter University name"),
        '#placeholder' => t('Enter your name here'),
        '#required'=> TRUE,


    );
    $form['address']=array(
        '#title'=>t("Unversity Address"),
        '#type'=> 'textfield',
        //'#value'=> t("Enter University address"),
        '#placeholder' => t('Enter your address here'),
        '#required'=> TRUE,


    );
     $form['#attributes']['enctype'] = 'multipart/form-data'; // If this is not
    // Here, upload will fail on submit
    // $form['#attributes']['placeholder'] = "Enter your input here";
   $form['logo'] = array(
        '#title'=> t('University Logo'),
        '#type'         => 'file',
        '#value'=>t("Enter University logo"),
        //'#required'=> TRUE,
        '#description'  => t('Images must be one of jpg, gif or png formats.'),

    );


$form['specialisation'] = array(
    '#type' => 'radios',
    '#title' => t('Choose your specialisation'),
    '#description' => t('Select a University Specialisation'),
    '#options' => array(
    t('Arts'),
    t('Commerce'),
    t('Science')),
    '#default_value' => isset($form_state['values']['specialisation']) ? $form_state['values']['specialisation'] : '',
    '#required'=> TRUE,
    );

    $form['website']=array(
        '#title'=>t("Univerity Website"),
        '#type'=>'textfield',
        //'#value'=>t("Enter University website"),
        '#placeholder' => t('Enter your website here'),
        '#required'=>TRUE,
    );

    $form['newsletter']=array(
        '#type'=>'checkbox',
        '#title'=>t("Do you want to receive newsletters in your email"),
        '#required'=>TRUE,
    );

    $form['submit']=array(
        '#type'=>'submit',
        '#value'=>'Submit',
        '#required'=>TRUE,
        '#submit' => array('mfrp_form_submit'),
        );

    return $form;    
}

提前致谢。

0 个答案:

没有答案