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

Formular mit ahah, drupal_set_cache tut nichts

Eingetragen von hnv (28)
am 22.01.2010 - 12:55 Uhr in
  • Modul-Entwicklung

Hallo alle,

ich brauche dringend eure Hilfe, mein Kopf zerbricht bald.

Ich schreibe ein Modul mit eigener Inhalttype. Mein Formular enthält ein ahah-Button „More Field“. In der test_more_field_js Funktion kann ich zwar die Anzahl der Felder mit drupal_get_cache ermitteln. Die Funktion drupal_set_cache scheint aber keine Wirkung zu haben. Ich erhalte immer nur gleiche Werte (2, ziehe Code).

Wo habe ich die Fehler?

/**
* Implementation of hook_form
**/
function test_form($node) {
$count = ($node->count) ? $node->count : 2;

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

for ($i=0;$i<$count;$i++) {
$form["field-$i"] = array(
'#type' => 'textfield',
'#title' => $i,
'#size' => 30,
);
}

$form['markup'] = array(
'#type' => 'markup',
'#value' => '<div id="add_more_field">&nbsp;</div>',
);

$form['more_field'] = array(
'#type' => 'button',
'#value' => t('More Field'),
//'#weight' => 6,
'#ahah' => array(
'event' => 'click',
'method' => 'before',
'path' => 'test_more_field_js',
'wrapper' => 'add_more_field',
),
'#suffix' => '<div style="clear:both"></div>',
);


return $form;
}



/**
* Ahah function to add more fields
**/
function test_more_field_js() {
include_once 'modules/node/node.pages.inc';
  $form_state = array('storage' => NULL, 'submited' => FALSE);
  $form_build_id = $_POST["form_build_id"];

$form = form_get_cache($form_build_id, $form_state);

$number = $form["count"]['#value'];

  // Preparing for #5.
  $args = $form['#parameters'];
  $form_id = array_shift($args);
  $form_state["post"] = $form["#post"] = $_POST;
  $form["#programmed"] = $form["#redirect"] = FALSE;
$form["count"]['#value'] = $number + 1;

  // Step #5.
  // drupal_process_form($form_id, $form, $form_state);
  // Step #6 and #7 and #8.
  // $form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id);

form_set_cache($form_built_id, $form, $form_state);
  $form += array(
    '#post' => $_POST,
    '#programmed' => FALSE,
  );

$field = array(
'#type' => 'textfield',
'#title' => $number,
);

$output = theme('status_messages') . drupal_render($field);

print drupal_to_js(array('status' => TRUE, 'data' => $output));
}

Vielen Dank für die Hilfe.

Grüße
hnv

‹ Tabellenausgabe mit theme('table',$header,$rows,$attributes) formatieren Problem mit LEFT JOIN in Select-Abfrage ›
  • Anmelden oder Registrieren um Kommentare zu schreiben

Benutzeranmeldung

  • Registrieren
  • Neues Passwort anfordern

Aktive Forenthemen

  • gepatchte PHP Version 7.4 für Windows
  • Canvas Palette: Eine fertige Komponentenbibliothek für Drupal Canvas
  • Hilfe zu Updates oder Composer
  • Vergleich Drupal und Contao
  • [geloest] Blocks in Bootstrap nebeneinander darstellen und nicht untereinander
  • DrupalCamp Frankfurt 27-28 November 2026
  • Bitte mein Bentzerkonto löschen
  • Beim Aufruf einiger Inhalte erhalte ich folgende Fehlermeldung
  • Neuinstallation: vermutlich ein rewrite-Problem
  • Drupal CMS installieren
  • [erledigt]MP3 in Drupal 10 einbinden
  • (gelöst)Drupal 11 installieren
Weiter

Neue Kommentare

  • Muss ja nicht genau php 8.3 sein
    vor 2 Tagen 22 Stunden
  • Guten morgen und Danke
    vor 3 Tagen 5 Stunden
  • Evtl. versuchen auf PHP 8 zu wechseln
    vor 3 Tagen 11 Stunden
  • Danke Schmittrich. Die Frage
    vor 5 Tagen 3 Stunden
  • Keine Antwort auf die Frage nach dem Woher
    vor 5 Tagen 6 Stunden
  • Danke ich werde mir die
    vor 6 Wochen 2 Tagen
  • Vielen Dank für Ihren
    vor 6 Wochen 5 Tagen
  • Composer ist sehr ratsam
    vor 7 Wochen 16 Stunden
  • Vielen Dank für den
    vor 7 Wochen 3 Tagen
  • Die alten CMS Vergleiche von contentmanager.de
    vor 7 Wochen 3 Tagen

Statistik

Beiträge im Forum: 250323
Registrierte User: 20571

Neue User:

  • alxshell
  • AnthonyhoF
  • Philiphelve

» Alle User anzeigen

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