|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
breizh Smarty n00b
Joined: 21 Oct 2004 Posts: 3
|
Posted: Thu Nov 25, 2004 5:45 pm Post subject: Daten ändern, die mit foreach ausgegeben wurden |
|
|
Hallo.
Ich habe folgendes Problem: Ich habe einen array,
Code: | $kaufteil = array(
array("artikel" => "k21", "menge" => $baK21, "modus" => $veK21),
array("artikel" => "k22", "menge" => $baK22, "modus" => $veK22), usw. |
den ich übergebe Code: | $smarty->assign("kt", $kaufteil); |
und der mir als Tabelle ausgegeben wird:
Code: | <table>{foreach name=aussen item=kt2 from=$kt}<tr>
{foreach key=schluessel item=wert from=$kt2}
<td>{$schluessel}: {$wert}</td>
{/foreach}</tr>
{/foreach}</table> |
Was ich jetzt möchte, ist folgendes: die Tabelle soll als Formular ausgegeben werden, damit Daten geändert werden können, die ich dann ans array zurückschicke, bzw. betreffende Variablen zu überschreiben.
Kann mir jemand helfen? Vielen Dank schonmal!
Gruß, Sascha |
|
Back to top |
|
T. Smarty Regular
Joined: 22 Aug 2004 Posts: 69 Location: AT
|
Posted: Thu Nov 25, 2004 7:47 pm Post subject: |
|
|
Hi!
Du müsstest die werte halt in ein textfeld (<input type="text" value="{$varname}" />) schreiben und die Namen der Textfelder auch dynamisch vergeben. Dann kannst du sie einfach in PHP wieder auslesen und dort die Werte überschreiben.
mfg Thomas _________________ Oppossom - Heavy rock from austria |
|
Back to top |
|
breizh Smarty n00b
Joined: 21 Oct 2004 Posts: 3
|
Posted: Thu Nov 25, 2004 11:59 pm Post subject: |
|
|
Danke für die Anwort!
Noch ne Frage (s. Code): ich möchte, das NUR die Menge über <input type="text" value="{$varname}" /> geändert werden kann, aber nicht der Artikel.
Wie müßte ich da meine Schleife anpassen?
mfg, Sascha |
|
Back to top |
|
T. Smarty Regular
Joined: 22 Aug 2004 Posts: 69 Location: AT
|
Posted: Fri Nov 26, 2004 7:12 am Post subject: |
|
|
Eine Möglichkeit wäre zu überprüfen, ob der Schlüssel gleich Menge ist, also in der schleife:
{if $schluessel eq "Menge"}
<td>{$schluessel}: <input type="text" Value="{$wert}" .... /></td>
{else}
<td>{$schluessel}: {$wert}</td>
{/if}
eine andere lösung wäre, dass du deine schleife anders aufbaust und nur eine foreach machst, hab das jetz ned so genau im kopf, würds außerdem mit section machen (foreach verwend ich nie)
<table>
{section name=aussen value=$kt} //bin mir ned sicher obs value heißt
<tr>
<td>Artikel: $kt[aussen].artikel</td>
<td>Menge: <input type="text" value="$kt[aussen].artikel" ... /></td>
<td>Modus: $kt[aussen].modus</td>
</tr>
{/section}
</table>
falls dich das interessiert müsstest halt in der Docu bei Sections nachlesen oder warten bis ich wieder mal nach haus komm.
mfg Thomas _________________ Oppossom - Heavy rock from austria |
|
Back to top |
|
breizh Smarty n00b
Joined: 21 Oct 2004 Posts: 3
|
Posted: Fri Nov 26, 2004 10:22 am Post subject: |
|
|
Um "$kt[aussen].artikel" und die anderen noch {} gemacht und es funzt!
Die erste Lösung geht auch. Vielen, vielen Dank! |
|
Back to top |
|
T. Smarty Regular
Joined: 22 Aug 2004 Posts: 69 Location: AT
|
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|