Re: Quickform and templates

From: Date: Wed, 26 Feb 2003 07:44:20 +0000
Subject: Re: Quickform and templates
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-13906@lists.php.net to get a copy of this message
I have never used Flexy or Xipe. Alan, do you think this architecture could work with Flexy ? When we will have something up and running with IT, do you feel like implementing something for Flexy ? For Flexy & Xipe (AFAIK), At the moment, there are no facilities to query a template - in terms of getting parts etc.. - I have been tossing around ideas of creating blocks in Flexy - mapped to PHP functions.. - it would probably work something like this..
<body flexyclass="MyApp_HTML_thispagename"> <div flexyfunction="zzzz"> <input name="xxx" flexyignore> <input name="theinput"> </div> </body> which would create an additional file : templatename.html.en.class.php <?php class MyApp_HTML_thispagename extends HTML_Template_FlexyClass {
     function zzzz($t) {
            $this->startBuffer();
               ?><input name="xxx">
   <INPUT NAME="theinput" VALUE="<?php echo htmlspecialchars($t->theform->theinput); ?>"><?php
if (isset($this->errors['theform.theinput'])) { echo htmlspecialchars($this->errors['theform.theinput']); } ?>
      ?>
      return $this->getBuffer();
    }
} ?> Although I think that adds a whole new layer of confusion and potential problems.... the only other way I could think of was <body > <form flexyUseQuickForm> <input name="xxx" QFRegex="[a-z0-9]*"> <input name="theinput"> </form> </body> // which would be compiled into <body > <?php echo $t->quickForm->toHTML(); ?> </body> .. or <body > <form><script ..... src='QF javascript' .... > <?php echo $t->quickForm->toHTML('xxx'); ?> <?php echo $t->quickForm->toHTML('theinput'); ?> </form> </body> which could generate an xml config file for QuickForms and you would have to do something like $template = new HTML_Template_Flexy($this->template); $template->compile(); $this->quickForm = new HTML_Quickform($template->getQuickFormXML()); if($this->quickForm->validate()) { $vars = $this->getForm->getData(); $obj = DB_DataObjects::staticGet('sometable',$vars['id']); $obj->setFrom($vars); $obj->update(); ... redirect somewhere... } ....... $template->outputObject($this); Currently Flexy is heading down the road of generating PHP code directly for the Form elements - although this still needs some more work but I am tempted to loose the speed advantages of this technique and utilize the work that has gone into HTML_QuickForms.. Regards Alan
Having a default layout block is also important if there is no per element block available in the template. Blocks for groups should maybe incorporate sub-blocks for elements contained in the group. There might also be a default block for elements in a group block. Here is a possible implementation for the initialization, but there are probably some other ways... 1. Instantiate a template object: $tpl = new HTML_Template_IT('.'); $tpl->setTemplate...('mytpl.tpl'); 2. Pass it to the HTML_QuickForm_Render constructor: $rend = new HTML_QuickForm_Render($tpl); 3. Inside the renderer, check the type of template object and choose the right class for the render methods. It might also be interesting to limit the rendering to just a few elements. This could be useful if we implement some kind of matrix rendering for example for grids. We could then have a part of the form rendered as a grid with x columns and y rows and the other part rendered using a template. It should also be possible to set a block for an element on runtime as I do at the moment with setElementTemplate(). Actually, it would be even better if we could set a block for more than just one element. The form template will probably need some special placeholders like {QF_JAVASCRIPT} {QF_START} {QF_END}. It shouldn't be compulsory to have error blocks inside element blocks. This way, we could have all errors reported on top of the form or anywhere else. We will probably need to change the way we deal with templates for required elements in QuickForm. We will need to add a default rendering for required elements. That's just some ideas... Feel free to comment. Thanks for jumping in. Bertrand Mansion Mamasam
-- Can you help out? Need Consulting Services or Know of a Job? http://www.akbkhome.com

« previous php.pear.dev (#13906) next »