Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Elemente aus Array richtig in das Template einbauen

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: German
View previous topic :: View next topic  
Author Message
Mario
Smarty n00b


Joined: 04 Aug 2004
Posts: 3

PostPosted: Thu Aug 05, 2004 1:35 pm    Post subject: Elemente aus Array richtig in das Template einbauen Reply with quote

Hallo!

Ich habe ein Formular unter Verwendung der PEAR-Klasse HTML_Quickform erstellt. (Auszug)

[php:1:17bf926c19]<?php
$form = new HTML_QuickForm('vat_new_Form','post','','_self',null,true);
$form->setRequiredNote('<span style="font-size:80%; color:#ff0000;">*</span><span style="font-size:80%;"> Kennzeichnet erforderliche Felder</span>');
$form->addElement('header','','Eingabe neuer MwSt Klassen und Werte');
$edit[0]=HTML_QuickForm::createElement('text', 'class', $tr->get('class'));
$edit[1]=HTML_QuickForm::createElement('text', 'value', $tr->get('value'));
// Variante 1
if(!strcmp($_GET['myaction'],'Aendern'))
{
$db = DB::connect($dsn);
$query='select * from mwst where mwst_id="'.$_GET['id'].'";';
$res = $db->query($query);
if (DB::isError($db))
{
die ($db->getMessage());
}
$mydata=$res->fetchRow(DB_FETCHMODE_ASSOC);
$edit[0]->setValue($mydata['klasse']);
$edit[1]->setValue($mydata['wert']);
$edit[2]=HTML_QuickForm::createElement('hidden', 'id_to_change');
$edit[2]->setValue($_GET['id']);
}
$edit[3]=HTML_QuickForm::createElement('submit', 'action', 'Speichern');
$edit[4]=HTML_QuickForm::createElement('reset', 'action', 'Zurücksetzen');
$form->addGroup($edit);

?>[/php:1:17bf926c19]

Mit Hilfe des HTML_QuickForm_Renderer_ArraySmarty erzeuge ich dann folgendes Array, das an Smarty übergeben wird. (Auszug)

Code:
Array
(
    [frozen] =>
    [javascript] =>
    [attributes] =>  action="/shop/admin/mwst.php" method="post" name="vat_new_Form" id="vat_new_Form"
    [requirednote] => * Kennzeichnet erforderliche Felder
    [errors] => Array
        (
        )

    [hidden] =>





    [sections] => Array
        (
            [0] => Array
                (
                    [header] => Eingabe neuer MwSt Klassen und Werte
                    [elements] => Array
                        (
                            [0] => Array
                                (
                                    [name] => qf_group_1
                                    [value] => Array
                                        (
                                            [action] => Zurücksetzen
                                        )

                                    [type] => group
                                    [frozen] =>
                                    [label] =>
                                    [required] =>
                                    [error] =>
                                    [separator] =>
                                    [elements] => Array
                                        (
                                            [0] => Array
                                                (
                                                    [name] => class
                                                    [value] =>
                                                    [type] => text
                                                    [frozen] =>
                                                    [label] => Klasse
                                                    [required] =>
                                                    [error] =>
                                                    [html] =>
                                                )

                                            [1] => Array
                                                (
                                                    [name] => value
                                                    [value] =>
                                                    [type] => text
                                                    [frozen] =>
                                                    [label] => Wert
                                                    [required] =>
                                                    [error] =>
                                                    [html] =>
                                                )

                                            [2] => Array
                                                (
                                                    [name] => action
                                                    [value] => Speichern
                                                    [type] => submit
                                                    [frozen] =>
                                                    [label] =>
                                                    [required] =>
                                                    [error] =>
                                                    [html] =>
                                                )

                                            [3] => Array
                                                (
                                                    [name] => action
                                                    [value] => Zurücksetzen
                                                    [type] => reset
                                                    [frozen] =>
                                                    [label] =>
                                                    [required] =>
                                                    [error] =>
                                                    [html] =>
                                                )

                                        )

                                )

                        )

                )


Im folgenden ist der Anfang meines Templates zu sehen mit dem Versuch die ersten Elemente einzufügen. Leider komme ich noch nicht mit der Syntax klar, d.h. die Ausgabe funktioniert nicht.

Code:

<html>
<head>
<title>Mehrwertsteuer</title>
<body>
<form {$vat_new_Form.attributes}>
{$vat_new_Form.hidden}
<table width="100%" border="1">
<tr><td>{$vat_new_Form.sections.0.elements.0.elements.0.class.label}</td><td>{$vat_new_Form.sections.0.elements.0.elements.0.class.html}</td></tr>
<tr><td>{$vat_new_Form.sections.0.elements.0.elements.0.value.label}</td><td>{$vat_new_Form.sections.0.elements.0.elements.0.value.html}</td></tr>
</table>
</form>
</body>
</html>


Vielleicht kann mir ja jemand hier einen Tip geben, was ich falsch mache, bzw. wie ich die Elemente des Array korrekt ins Template einfüge.

Mario
Back to top
View user's profile Send private message
Mario
Smarty n00b


Joined: 04 Aug 2004
Posts: 3

PostPosted: Thu Aug 05, 2004 7:37 pm    Post subject: Reply with quote

Nun hab ich es durch hartnäckiges Probieren doch noch rausbekommen.
Das ist die richtige Form.
Code:

{$vat_new_Form.sections.0.elements.0.elements.0.label}
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: German All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP