Search code examples
htmlcssdrupaldrupal-formsdrupal-webform

Is it possible to transfer an HTML form to a webform? Drupal


I have already made and styled an HTML form, is it possible to put it into a webform in Drupal, without having to create everything again? I mean, Is it possible to take the ids and classes to made the webform module take the results submitted?


Solution

  • Answer is mixed. You can reuse the styling you have already done in html form but it is not as simple as copy-pasting the html form in drupal.

    You need to use drupal form api for this purpose.

    Drupal 6 form example: http://drupal.org/node/717734
    Drupal 7 form example: http://drupal.org/node/717740

    Drupal 6 field example:

    $form['title'] = array(
      '#type' => 'textfield',
      '#title' => t('Page title'),
      '#attributes' => array(
        'class' => 'page-title', 
      ),
    );
    

    Drupal 7 field example:

    $form['title'] = array(
      '#type' => 'textfield',
      '#title' => t('Page title'),
      '#attributes' => array(
        'class' => array('page-title'), 
      ),
    );