Startseite
  • » Home
  • » Handbuch & FAQ
  • » Forum
  • » Übersetzungsserver
  • » Suche
Startseite › Forum › Drupalcenter.de › Module ›

[gelöst]Dynamische Form

Eingetragen von dontgotanick (156)
am 23.07.2010 - 13:41 Uhr in
  • Module
  • Drupal 6.x

Hi,

ich versuche ein Auswahl menu zu erstellen.
Bei dem ich erst das Jahr auswähle und dann einen Titel einer Node aus diesem Bereich.

Leider funktioniert das nicht so ganz habe mich daran versucht bin aber geshceitert......

Kann mir jemand sagen was ich falshc mache?

Hier mal der Code

<?php


<?php
// $Id$

/**
* Valid permissions for this module
* @return array An array of valid permissions for the signup_export module
*/
   
function cwg_signup_export_perm() {
        return array(
'access signup_export');
    }
// function cwg_registration_perm()
   
   
function cwg_signup_export_menu() {

       
$items = array();

       
$items['admin/settings/cwg_signup_export'] = array(
       
'title' => 'CWG-Export-Signups',
       
'description' => 'Exports Signups for certain events.',
       
'page callback' => 'drupal_get_form',
       
'page arguments' => array('cwg_signup_export_admin'),
       
'access callback' =>  'user_access',
       
'access arguments' => array('access signup_export'),
       
'type' => MENU_NORMAL_ITEM,
        );

        return
$items;
    }
   
/**
* Define the settings form.
*/
   
function cwg_signup_export_admin($param1, $form_values = NULL) {
       
       
        if (!isset(
$form_values)) {
           
$step = 1;
        }
        else {
           
$step = $form_values['step'] + 1;
        }

       
$form['step'] = array(
       
'#type' => 'hidden',
       
'#value' => $step,
        );

        switch (
$step) {
        case
1:
           
$form['event_signup_list']['year'] = array(
           
'#type' => 'select',
           
'#title' => t('Select the year of the event.'),
           
'#options' => get_years(),
        );

        break;

        case
2:
       
$form['event_signup_list']['year'] = array(
           
'#type' => 'select',
           
'#title' => t('Select the year of the event.'),
           
'#options' => options($form_values['year']),
        );

        break;

        }

       
// This part is important!
       
$form['#multistep'] = TRUE;
       
$form['#redirect'] = FALSE;

       
$form['submit'] = array(
       
'#type' => 'submit',
       
'#value' => 'save',
        );

return
$form;
}
       
    function
options($value){
       
       
$sql = "SELECT title,changed FROM {node} WHERE nid <>'0' and type='event'";
       
       
$options = array();
       
$count = 0;
       
$result = db_query($sql);
       
        while(
$row = db_fetch_object($result)){
       
$year = date(Y, $row->changed);
        if(
$value = $year)
           
$options[$count++] = $row->title;
        }
   
        return
$options;
   
    }
   
    function
get_years(){

   
$years = array();
   
$count = 0;
   
$insert = true;
   
$sql = "SELECT changed FROM {node} WHERE nid<>0 AND type='event'";
   
$result = db_query($sql);
       
        while(
$row = db_result($result)){
       
       
$year = date(Y,$row);
       
        foreach (
$years as &$value) {
            if(
$value == $year)
               
$insert = false;
            else
               
$insert = true;
        }
               
        if(
$insert)       
           
$years[$count++] = $year;
        }
       
        return
$years;

    }
   
   
    function
cwg_signup_export_admin_submit($form, &$form_state){
   
   
$final_step = 3;

    if (
$form_values['step'] == $final_step) {
       
// Process the form here!
           
get_years();
    }


   
/**    $nid;
        if($_POST['Filter'] === 'all'){
        $t=options();
        $sql = "SELECT nid FROM {node} WHERE title LIKE '%s'";
        $nid = db_result(db_query($sql, $t[$_POST['All']]));
        }
        else{
            $sql = "SELECT nid FROM {signup} WHERE nid !='0' and status='1'";
            $nid = db_result(db_query($sql));
        }
       
       
       
        $sql = "SELECT form_data,uid FROM {signup_log} WHERE nid = '%d'";
        $db_result = db_query($sql, $nid);
       

        $out = "Username;Name;Surname;Company;Email;";
        $n = "\n";
        $first = true;
        while($row = db_fetch_object($db_result)){

            $uid = $row->uid;
            $sql = "SELECT value FROM {profile_values} where uid='%d' and fid='1'";
            $surname = db_result(db_query($sql,$uid));
            $sql = "SELECT value FROM {profile_values} where uid='%d' and fid='2'";
            $name = db_result(db_query($sql,$uid));
            $sql = "SELECT value FROM {profile_values} where uid='%d' and fid='11'";
            $company = db_result(db_query($sql,$uid));
            $sql = "SELECT name FROM {users} where uid='%d'";
            $username = db_result(db_query($sql,$uid));
            $sql = "SELECT mail FROM {users} where uid='%d'";
            $mail = db_result(db_query($sql,$uid));
           
           
           
            $form_data = unserialize($row->form_data);
           
            foreach ($form_data as $key => $value) {
            if ($first) {
                $out .= $key . ";";
            }

            if (is_array($value)) {
                $isFirst = true;
                foreach ($value as $arrayKey => $arrayValue) {
                    if ($arrayValue !== 0) {
                        if($isFirst) {
                            $isFirst = false;
                            $arrayValues .= check_plain($arrayKey);
                        }
                        else {
                            $arrayValues .= ", " . check_plain($arrayKey);
                        }
                    }
                }
                $rowValue .= check_plain($arrayValues) . ";";
                $arrayValues = "";

            } else {
                $rowValue .= check_plain($value) . ";";
            }
            }
            if ($first) {
            $out .= "\n";
            $first = false;
            }
            $out .= $username . ";" . $name . ";" . $surname . ";" . $company . ";" . $mail . ";" . $rowValue . $n;
            $rowValue = "";
           
        }
       
       
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Content-Length: " . strlen($out));
    header("Content-type: text/x-csv");
    header("Content-Disposition: attachment; filename=export.csv");
    echo $out;
    **/
   
}
       








?>

danke

lg dave

‹ WYSIWYG auch für CCK-Felder Kontaktformular mit eigenen Feldern ? ›
  • Anmelden oder Registrieren um Kommentare zu schreiben

Schau Dir mal das folgende

Eingetragen von Sense (1518)
am 23.07.2010 - 13:51 Uhr

Schau Dir mal das folgende Tutorial an um Multistep Formulare zu bauen: http://www.andrewyager.com/content/view/51/27/

sense-design | online solutions | Do not hack core!
Drupalcenter Verhaltensregeln | Threads bitte auf [gelöst] stellen.

  • Anmelden oder Registrieren um Kommentare zu schreiben

super

Eingetragen von dontgotanick (156)
am 23.07.2010 - 15:35 Uhr

danke hat geklappt

  • Anmelden oder Registrieren um Kommentare zu schreiben

Benutzeranmeldung

  • Registrieren
  • Neues Passwort anfordern

Aktive Forenthemen

  • Matomo(?) in Seite, aber Deinstalliert!
  • Upgrade Drupal 7 auf Drupal 9 / Inhalt erstellen zeigt nur Fehler an
  • Olivero veraendern
  • Fehlermeldung nach Update auf Drupal 10
  • Wie Button erstellen?
  • footnotes bei D10 und CKE5
  • ckeditor Bilder skalieren
  • Bild in welcher Form die Beschriftung!
  • Drupal 10 und Adaptive Theme 2.0
  • Drupal Commerce: Deprecated Module deinstallieren: CKEditor, RDF
  • [gelötst] Migration einer Seite von D8.9 auf 9 resp 10
  • Theme Olivero - Rand entfernen?
Weiter

Neue Kommentare

  • @onkel Bob,Erst mal
    vor 5 Tagen 14 Stunden
  • Prinzipiell geht das schon.
    vor 5 Tagen 15 Stunden
  • Rubi_2021 schriebWie genau
    vor 1 Woche 4 Tagen
  • Ok, war ein Versuch. ;-) Kann
    vor 1 Woche 4 Tagen
  • Danke
    vor 1 Woche 4 Tagen
  • Redest Du von dem
    vor 1 Woche 4 Tagen
  • Mit sticht das hier ins
    vor 1 Woche 4 Tagen
  • Mit welcher Version Drupal
    vor 1 Woche 4 Tagen
  • Bitte um Hilfe
    vor 1 Woche 5 Tagen
  • Fehler trotz Neuinstallation
    vor 1 Woche 5 Tagen

Statistik

Beiträge im Forum: 248796
Registrierte User: 19831

Neue User:

  • J. Berten
  • vohome
  • DerRalph

» Alle User anzeigen

User nach Punkten sortiert:
wla9333
stBorchert6003
quiptime4972
Tobias Bähr4019
bv3924
ronald3845
md3717
Thoor3678
Alexander Langer3416
Exterior2903
» User nach Punkten
Zur Zeit sind 0 User und 5 Gäste online.

Hauptmenü

  • » Home
  • » Handbuch & FAQ
  • » Forum
  • » Übersetzungsserver
  • » Suche

Quicklinks I

  • Infos
  • Drupal Showcase
  • Installation
  • Update
  • Forum
  • Team
  • Verhaltensregeln

Quicklinks II

  • Drupal Jobs
  • FAQ
  • Drupal-Kochbuch
  • Best Practice - Drupal Sites - Guidelines
  • Drupal How To's

Quicklinks III

  • Tipps & Tricks
  • Drupal Theme System
  • Theme Handbuch
  • Leitfaden zur Entwicklung von Modulen

RSS & Twitter

  • Drupal Planet deutsch
  • RSS Feed News
  • RSS Feed Planet
  • Twitter Drupalcenter
Drupalcenter Team | Impressum & Datenschutz | Kontakt
Angetrieben von Drupal | Drupal is a registered trademark of Dries Buytaert.
Drupal Initiative - Drupal Association