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

ahah: mehrere Form-Elemente bei Select-change ändern

Eingetragen von jeho (3)
am 07.05.2009 - 12:39 Uhr in
  • Modul-Entwicklung
  • Drupal 6.x

Hallo Leute!

Ich habe hier ein Registrierungs-Formular in einem eigenen Modul "custom" mit 4 Selects, die von einander abhängig sind:
Firma -> Land -> Stadt -> Adresse
Wenn ich eine Firma auswähle, wird per ahah das Land-Select gefüllt. Wenn ich dann ein Land auswähle, erhält das Stadt-Select entsprechende Einträge etc.

Mein Problem nun: Habe ich alle 4 gewählt und wähle dann eine andere Firma, müssen Stadt und Adresse geleert werden bzw. mit "---" gefüllt (Land wird ja schon durch ahah gefüllt). Bei Auswahl eines Landes muss entsprechend das Adress-Select geleert werden.

Wie setzte ich das nun in meiner Funktion um? Habe schon diverse Ansätze versucht, nichts klappt. Hier die Funktion, die nach der Firmenwahl das Land-Select füllt:

<?php

function custom_registration_get_company_countries_js()
{
   
// Get the new values
   
$new_company_countries = custom_registration_get_company_countries($_POST['company']);

   
// Get form from cache and store modified place selection
   
$form_state = array('storage' => NULL, 'rebuild' => TRUE);
   
$form = form_get_cache($_POST['form_build_id'], $form_state);
 
   
// Select neu setzen
   
$form['account']['country'] = array(
       
'#type' => 'select',
       
'#title' => t('Country'),
       
'#required' => TRUE,
       
'#options' => $new_company_countries,
       
'#description' => t('Helptext for the agencies country select'),
       
'#weight' => 11,
    );

   
form_set_cache($_POST['form_build_id'], $form, $form_state);
   
$form += array(
       
'#post' => $_POST,
       
'#programmed' => FALSE,
    ); 
 
   
// Rebuild the form.
   
$form_state = array('submitted' => FALSE);
   
$form = form_builder('user-register', $form, $form_state);

   
// Render the new output.
   
$output = theme('status_messages') . drupal_render($form['account']['country']);

   
// Don't call drupal_json(). ahah.js uses an iframe and
    // the header output by drupal_json() causes problems in some browsers.
   
print drupal_to_js(array('status' => TRUE, 'data' => $output));
    exit;
}
?>

Hier müsste also irgendwie sowas rein:

<?php

   $form
['account']['city']['#options'] = array('0' => '---');
  
$form['account']['agencies_addresses']['#options'] = array('0' => '---');
?>

Ich habe auch schon versucht, das Element einfach anzuhängen. Das geht zwar, aber dann ist die Select-Box (logischereise) zweimal vorhanden, weil sie jetzt in einem anderen Wrapper gerendert wird.

<?php

function custom_registration_get_company_countries_js()
{
   
$new_company_countries = custom_registration_get_company_countries($_POST['company']);

   
// Get form from cache and store modified place selection
   
$form_state = array('storage' => NULL, 'rebuild' => TRUE);
   
$form = form_get_cache($_POST['form_build_id'], $form_state);
 
   
// Select neu setzen
   
$form['account']['country'] = array(
       
'#type' => 'select',
       
'#title' => t('Country'),
       
'#required' => TRUE,
       
'#options' => $new_company_countries,
       
'#description' => t('Helptext for the agencies country select'),
       
'#weight' => 11,
    );
   
$form['account']['city'] = array(
       
'#type' => 'select',
       
'#title' => t('City'),
       
'#required' => TRUE,
       
'#options' => array('0' => '---'),
       
'#description' => t('Helptext for the agencies city select'),
       
'#weight' => 12,
    );

   
form_set_cache($_POST['form_build_id'], $form, $form_state);
   
$form += array(
       
'#post' => $_POST,
       
'#programmed' => FALSE,
    ); 
 
   
// Rebuild the form.
   
$form_state = array('submitted' => FALSE);
   
$form = form_builder('user-register', $form, $form_state);

   
// Render the new output.
   
$output = theme('status_messages') . drupal_render($form['account']['country']) . drupal_render($form['account']['city']);

   
// Don't call drupal_json(). ahah.js uses an iframe and
    // the header output by drupal_json() causes problems in some browsers.
   
print drupal_to_js(array('status' => TRUE, 'data' => $output));
    exit;
}

?>

Kann mir jemand helfen?

Grüße Jens

‹ Private Nachrichten und Rollen Datenbank Update Problem ›
  • Anmelden oder Registrieren um Kommentare zu schreiben

Benutzeranmeldung

  • Registrieren
  • Neues Passwort anfordern

Aktive Forenthemen

  • für drupal11 ein Slider Modul
  • [gelöst] W3CSS Paragraphs Views
  • Drupal 11 neu aufsetzen und Bereiche aus 10 importieren
  • Wie erlaubt man neuen Benutzern auf die Resetseite zugreifen zu dürfen.
  • [gelöst] Anzeigeformat Text mit Bild in einem Artikel, Drupal 11
  • Social Media Buttons um Insteragram erweitern
  • Nach Installation der neuesten D10-Version kein Zugriff auf Website
  • Composer nach Umzug
  • [gelöst] Taxonomie Begriffe zeigt nicht alle Nodes an
  • Drupal 11 + Experience Builder (Canvas) + Layout Builder
  • Welche KI verwendet ihr?
  • Update Manger läst sich nicht Installieren
Weiter

Neue Kommentare

  • melde mich mal wieder, da ich
    vor 2 Wochen 22 Stunden
  • Hey danke
    vor 2 Wochen 1 Tag
  • Update: jetzt gibt's ein
    vor 2 Wochen 2 Tagen
  • Hallo, im Prinzip habe ich
    vor 2 Wochen 6 Tagen
  • Da scheint die Terminologie
    vor 3 Wochen 1 Minute
  • Kannst doch auch alles direkt
    vor 3 Wochen 4 Tagen
  • In der entsprechenden View
    vor 3 Wochen 4 Tagen
  • Dazu müsstest Du vermutlich
    vor 3 Wochen 4 Tagen
  • gelöst
    vor 6 Wochen 19 Stunden
  • Ja natürlich. Dass ist etwas,
    vor 6 Wochen 1 Tag

Statistik

Beiträge im Forum: 250233
Registrierte User: 20452

Neue User:

  • ByteScrapers
  • Mroppoofpaync
  • 4aficiona2

» Alle User anzeigen

User nach Punkten sortiert:
wla9461
stBorchert6003
quiptime4972
Tobias Bähr4019
bv3924
ronald3857
md3717
Thoor3678
Alexander Langer3416
Exterior2903
» User nach Punkten
Zur Zeit sind 0 User und 17 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