PEAR Forum :: PHP Extension and Application Repository

PEAR Forum Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
[solved]Renderers not working :/

 
Post new topic   Reply to topic    PEAR Forum Forum Index -> HTML
View previous topic :: View next topic  
Author Message
piotrekkr



Joined: 28 Apr 2008
Posts: 1

PostPosted: Mon Apr 28, 2008 7:38 pm    Post subject: [solved]Renderers not working :/ Reply with quote

Hi. I have problem with renderers ArraySmarty or Array (both aren't working). This is my code:
Code:

require_once('HTML/QuickForm.php');
         require_once 'HTML/QuickForm/Renderer/ArraySmarty.php';
         
         $form = new HTML_QuickForm('form_add', 'post', $this->CreateLink(array('act' => 'AddNews'), '', true, '', false));
         
         $form->addElement('text', 'title', 'Tytuł:', array('size' => 20, 'maxlength' => 255));
         $renderer =& new HTML_QuickForm_Renderer_ArraySmarty();
         $form->accept($renderer);
         
         $items = array();
         if(!empty($categories))
         {
            $items = array('0' => 'Wybierz');
            foreach($categories as $val)
            {
               $items[$val['category_id']] = $val['category_name'];
            }
         }
         $form->addElement('select', 'category_id', 'Kategoria:', $items);
         
         $form->addElement('textarea', 'short_version', '', array('wrap' => 'soft', 'class' => 'TinyMce'));
         $form->addElement('textarea', 'all_content', '', array('wrap' => 'soft', 'class' => 'TinyMce'));
         $items = array(
            '1' => 'Aktywny',
            '0' => 'Nieaktywny');
         $form->addElement('select', 'default_state', '', $items);
         $form->addElement('submit', 'add_submit', 'Dodaj');
         //$form->display();
         $this->smarty->assign('add_news_form', $renderer->toArray());
         var_dump($renderer->toArray());

var_dump shows that only title element was returned. There is no select lists or textareas:
Code:
array(7) {
  ["frozen"]=>
  bool(false)
  ["javascript"]=>
  string(0) ""
  ["attributes"]=>
  string(93) " action="index.php?mod=NewsPanel&act=AddNews" method="post" name="form_add" id="form_add""
  ["requirednote"]=>
  string(111) "<span style="font-size:80%; color:#ff0000;">*</span><span style="font-size:80%;"> denotes required field</span>"
  ["errors"]=>
  array(0) {
  }
  ["hidden"]=>
  string(0) ""
  ["title"]=>
  array(8) {
    ["name"]=>
    string(5) "title"
    ["value"]=>
    NULL
    ["type"]=>
    string(4) "text"
    ["frozen"]=>
    bool(false)
    ["required"]=>
    bool(false)
    ["error"]=>
    NULL
    ["label"]=>
    string(7) "Tytuł:"
    ["html"]=>
    string(60) "<input size="20" maxlength="255" name="title" type="text" />"
  }
}

When I use $form->display() it shows all fields but i can't return it ass array to smarty:( Plz help

PS. sorry for my poor english.

######EDIT
Ok I figured out what was wrong.
This
Code:

$renderer =& new HTML_QuickForm_Renderer_ArraySmarty();
$form->accept($renderer);

should be just before
Code:

$this->smarty->assign('add_news_form', $renderer->toArray());

I guess that method accept() transfers form data to renderer. So it should be transfered after creating form elements.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PEAR Forum Forum Index -> HTML All times are GMT + 2 Hours
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



PEAR Forum topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group

Provided by Ministry of Web developement

'Actiemonitor' online projectmanagement software