|
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 |
NullPlan Smarty n00b
Joined: 11 Sep 2004 Posts: 3
|
Posted: Thu Mar 03, 2005 12:47 pm Post subject: Indiziertes Array in Smarty nutzen |
|
|
Hi,
wie kann ich ein indiziertes Array in Smarty nutzen bzw. zuweisen?
Ich habe folgendes vor:
php:
Code: |
$sel = array(0 => '', 1 => 'selected="selected"');
$smarty->assign($sel);
|
Template:
Code: |
<select name="bla">
<option value="0" {$sel[0]}>blub</option>
<option value="1" {$sel[1]}>foo</option>
</select>
|
Problem: $sel steht in Smarty garnicht zur Verfügung, zumindest nicht über den obigen Aufruf.
Mit assoziativen Arrays klappt das natürlich problemlos, doch diese möchte ich in diesem Fall nicht nutzen.
cu |
|
Back to top |
|
coach Smarty Regular
Joined: 03 Jun 2004 Posts: 65
|
|
Back to top |
|
ZakMc Smarty Pro
Joined: 04 Oct 2004 Posts: 182
|
Posted: Mon Mar 07, 2005 10:30 am Post subject: |
|
|
das assign ist doch schon falsch, woher weiss smarty denn das das zugewiesene array im template $sel heissen soll.
es muss $smarty->assign("sel", $sel); heissen.
ansonsten sollte es richtig sein.
Wäre es nicht leiter wenn du das dropdown von smarty komplett zusammenbauen lässt mit einer section, bevor du alle möglichkeiten per hand einträgst???!! |
|
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
|