Login | Register
My pages Projects Community openCollabNet

Discussions > users > Re: [propel] more on propel, forms, arrays

propel
Discussion topic

Back to topic list

Re: [propel] more on propel, forms, arrays

Reply

Author Compte messagerie <compte_messagerie at hotmail dot com>
Full name Compte messagerie <compte_messagerie at hotmail dot com>
Date 2005-04-22 10:51:09 PDT
Message i think a lotf of pepople are building their own *framework* with different
block,

i personnaly think the most revelant part of this is how you handle "client
event", or how do you react to url, so what would be the form action...
and there's so many solutions...
html generation can be hassle, but automagicly generate html will cause you
hassle if you want to customize, event with template engine like smarty or
another one, how would you work together with a designer? you'll have to
create some custom tag for him to use and to learn, or do the integration
yourseilf...

so as long as the buils tools allows customization , th same way propel 2
with the builder, it should fit anybody custom solution...

could the form tool provide some sort of interface that then each developper
would use to use with its "UI" layer...

just thinking loud to myself, fell free to comment...


>From: Marc <therebel at free dot fr>
>Reply-To: users at propel dot tigris dot org
>To: users at propel dot tigris dot org
>Subject: Re: [propel] more on propel, forms, arrays
>Date: Fri, 22 Apr 2005 19:42:26 +0200
>
>Very interesting topic !!
>
>I have some ideas too about form generation that would be, in my opinion a
>additionnal target of phing ..
>
>For information, I have done some simple tests with good result with Propel
>OM + Pear QuickForm + Smarty.
>
>The idea is to generate a simple form that is based exactly on OM, by using
>a smarty template.. Then, for more customized results, create a
>configuration file for additionnal information about a field
>If it's a blob type, for example, option to display a HTML wisywyg editor
>If it's a foreign key, indicate the field in parent table that will contain
>the text value.
>...
>
>The idea of an independant Framework based on Propel is for me a good idea
>..
>
>for information,
>My _very simple_ source code test : The result is a form with input text
>of length variable (depends on length of database field) :
>
>[smarty/setup.inc.php]
>
><?
>$path_smarty = "/usr/share/pear/smarty/libs";
>set_include_path​(get_include_path() . PATH_SEPARATOR . $path_smarty);
>// load class
>require "Smarty.class.php";
>// instantiate object
>$tpl = new Smarty();
>// initialize
>$tpl->template_dir = 'smarty/templates/';
>// (templates_c needs to be server-writeable)
>$tpl->compile_dir = 'smarty/templates_c/';
>$tpl->config_dir = 'smarty/configs/';
>$tpl->cache_dir = 'smarty/cache/';
>
>
>?>
>
>
>
>
>[test.php]
>
><?
>require('HTML/Qu​ickForm/Renderer/Arr​aySmarty.php');
>require_once 'HTML/QuickForm.php'; ///usr/home/dmintz/inc/pear/
>include "smarty/setup.inc.php";
>
>
>$path_propel_projet =
>"/usr/share/pear​/data/propel_generat​or/projects/reportin​g/build/";
>$path_propel_classes = $path_propel_projet."classes/";
>set_include_path​(get_include_path() . PATH_SEPARATOR .
>$path_propel_classes. PATH_SEPARATOR . $path_propel_projet);
>
>// Initialize Propel using path to the converted
>// property file that was created with the convert-props phing target
>require_once 'propel/Propel.php';
>Propel::init('co​nf/reporting-conf.ph​p');
>
>include_once 'reporting/Report.php';
>// include_once 'reporting/ReportDat​asource.php';
>
>require_once("pr​opel/map/DatabaseMap​.php");
>
>
>
>
>
>// Load the main class
>
>
>// Instantiate the HTML_QuickForm object
>$form = new HTML_QuickForm('firs​tForm','GET');
>
>
>try {
>
>$dbMap = Propel::getDatabaseM​ap("reporting");
>
>$tables = $dbMap->getTables();
>
>
>foreach ($tables as $tableName => $table) {
> if($tableName=="report")
> {
> print "Table: $tableName\n";
> $columns = $table->getColumns();
> foreach ($columns as $column) {
> $creoleType = CreoleTypes::getCreo​leName($column->​getCreoleType());
>
> if($column->getSize()>0)
> {
> $tmp['size'] = $column->getSize();
> $tmp['maxlength'] = $column->getSize();
> }
> else
> {
> $tmp['size'] = 3;
> $tmp['maxlength'] = 3; }
> $form->addElement('text',
>$column->get​ColumnName(),$colum​n->getColumnName(​), $tmp);
> }
> }
>}
>
>
>} catch (Exception $e) {
>die("Exception: " . $e);
>}
>
>
>$form->addEl​ement('submit', 'envoi', 'Envoyer');
>
>
>
>/* end form definition stuff */
>
>
>
>
>
>// Step 1: instantiate
>//whereas before we pulled the default renderer out of our QuickForm
>// object and customized it, now we create one of these instead
>$renderer =& new HTML_QuickForm_Rende​rer_ArraySmarty($tp​l);
>
>// Step 3: accept()
>// build the HTML for the form (a la Visitor Design Pattern)
>$form->accep​t($renderer);
>
>unset($fields);
>unset($form);
>/// Separate form info in $form array and fields info in $fields array
>foreach($render​er->toArray() as $tmp_id => $aryInfos)
>{
> if(is_array($aryInfos))
> {
> if(!empty($aryInfos['html']))
> {
> // il s'agit d'un champ
> $fields[strtolower($tmp_id)] = $aryInfos;
> }
> else
> {
> $form[$tmp_id] = $aryInfos;
> }
> }
> else
> {
> $form[$tmp_id] = $aryInfos;
> }
>}
>
>// Step 4: assign array of form data to a variable template
>$tpl->assign('form', $form);
>$tpl->assign('fields', $fields);
>
>
>// Step 5: display the template and away you go
>$tpl->displa​y('form.tpl');
>
>
>?>
>
>[form.tpl]
>
>{literal}<style type="text/css">
> .errorMessage {
> color:red;
> /* et cetera. */
> }
></style>{/literal}
>
>{* if the $form uses client-side validation, $form.javascript is essential
>otherwise the onsubmit handler will call a nonexistent function and fail.
>also,
>we could have placed this in the HEAD of the document if we pleased.
>*}
>
>{$form.javascript}
>
>{if $form.errors}
> <p style="font-size:14pt">Form ok (as noted below)</p>
>{elseif $response}
> <p style="font-size:14pt">Form NOT ok (as noted below)</p>
>{/if}
>
><form {$form.attributes}>
><table summary="beer selection form" border="0">
> {foreach key=field_id item=field from=$fields}
> <tr>
> <td align="right" valign="top">
> <span style="color: #ff0000">*</span>
> {$field.label}</td>
> <td valign="top" align="left">
> {if $field.error}<span class="errorMessage">
> {$field.error}</​span><br />
> {/if}
> {$field.html}
> </td>
> </tr>
> {/foreach}
>
> <tr>
> <td colspan="2" align="center" valign="top" align="left">
> {$form.envoi.html}
> </td>
> </tr>
> <tr>
> <td colspan="2" align="center" valign="top" align="left">
> <span class="errorMessage"​>*</span>
> <span style="font-size:80%;"> denotes required field</span>
> </td>
> </tr>
></table>
></form>
>
>
>
>
>
>Sven Fuchs a écrit :
>
>>(To first introduce myself shortly: I'm not too experienced in using
>>Propel yet - just played around with it a bit. But I've been lurking
>>the lists for months. Propel is my option #1 for future projects.)
>>
>>I'd like to throw in these comments though:
>>
>>
>>
>>>My main concern right now is what kind of flexible solution could be
>>>employed such that the schema could be extended to include information
>>>like form data -- e.g. paths to widgets / templates to use, etc. I like
>>>the idea of having a data model that is only that (i.e. keep display
>>>stuff out of schema), but then having some other way (another xml file?
>>>or...?) to add stuff that is related to the data model -- like forms.
>>>
>>>
>>
>>To me, one of the main advantages of Propel really is that it's
>>*focussing* on its main job: providing an ORM. I'd therefor strongly
>>agree with separating the data model (as a part of the domain) from
>>more presentational stuff like forms.
>>
>>I'd even propose, that: if the distinction between a db abstraction
>>layer (Creole) and an ORM layer (Propel) is reasonable and good than
>>a clear seperation between Propel and a layer that _uses_ Propel to
>>build forms, objects, handles request etc. should be reasonable and
>>good. Perhaps ... this would be another project?
>>
>>Don't get me wrong. I completely agree with this:
>>
>>
>>
>>> This is IMO display stuff & should be kept elsewhere. I do like,
>>>however, the idea of having some place where defaults like that could be
>>>specified -- from a RAD perspective, that could be very useful.
>>>
>>>
>>
>>Yes, it would. And I think, Propel could make an awsome foundation for
>>some RAD form/object handling stuff.
>>
>>But I think,
>>
>>1. this should be realized as a project different from (but build on
>> top of) Propel
>>2. even if it's integrated in Propel, it should be as clearly
>> separated as ever possible from the (existing) ORM stuff (so that
>> users like me don't shy away from "the next bloated thing")
>>
>>Ideally, I'd imagine a neat separate form builder project that nicely
>>integrates with Propel leaving request/response/... management to the
>>user (or framework or whatever).
>>
>>Talking about forms: have you ever had a look at patForms [1]? It has
>>a very clear design (seperating each task) and I've heard about plans
>>to integrate with Propel. Probably a chance to avoid re-doing stuff
>>that's already done?
>>
>>... just 2 pence from a not-yet-user.
>>
>>
>>Besides all that let me thank you very much for your great work! I've
>>been recently playing around with Propel for the first time and I'm
>>very impressed about it. :)
>>
>>Regards,
>>Sven
>>
>>
>>[1] patForms - http://www.php-tools​.de/site.php?file=pa​tForms/overview.xml
>>
>>
>>------------​--------------------​--------------------​-----------------
>>To unsubscribe, e-mail: users-unsubscribe@pr​opel.tigris.org
>>For additional commands, e-mail: users-help at propel dot tigris dot org
>>
>>
>>
>
>
>----------------​--------------------​--------------------​-------------
>To unsubscribe, e-mail: users-unsubscribe@pr​opel.tigris.org
>For additional commands, e-mail: users-help at propel dot tigris dot org
>

____________________​____________________​____________________​_____
MSN Messenger : personnalisez votre messagerie instantanée !
http://g.msn.fr/FR1001/866

« Previous message in topic | 1 of 16 | Next message in topic »

Messages

Show all messages in topic

Re: [propel] more on propel, forms, arrays Compte messagerie <compte_messagerie at hotmail dot com> Compte messagerie <compte_messagerie at hotmail dot com> 2005-04-22 10:51:09 PDT
     Re: [propel] more on propel, forms, arrays Marc <therebel at free dot fr> Marc <therebel at free dot fr> 2005-04-22 11:23:21 PDT
         Re: [propel] more on propel, forms, arrays Compte messagerie <compte_messagerie at hotmail dot com> Compte messagerie <compte_messagerie at hotmail dot com> 2005-04-22 11:23:27 PDT
             Re: [propel] more on propel, forms, arrays Markus Wolff <wolff at 21st dot de> Markus Wolff <wolff at 21st dot de> 2005-04-23 15:08:18 PDT
                 Re: [propel] more on propel, forms, arrays rhalff Rob Halff 2005-04-23 14:13:23 PDT
                     Re: [propel] more on propel, forms, arrays Markus Wolff <wolff at 21st dot de> Markus Wolff <wolff at 21st dot de> 2005-04-23 18:49:39 PDT
                         RE: [propel] more on propel, forms, arrays cyruzb Bert Van den Brande 2005-04-26 12:36:56 PDT
                             Re: [propel] more on propel, forms, arrays hlellelid Hans Lellelid 2005-04-26 12:53:20 PDT
                                 Re: [propel] more on propel, forms, arrays cyruzb Bert Van den Brande 2005-04-26 22:41:37 PDT
                                     Re: [propel] more on propel, forms, arrays rhalff Rob Halff 2005-04-26 23:23:11 PDT
                                         Re: [propel] more on propel, forms, arrays cyruzb Bert Van den Brande 2005-04-27 02:39:16 PDT
                                         Re: [propel] more on propel, forms, arrays hlellelid Hans Lellelid 2005-04-27 04:32:05 PDT
                                             setByName eustache Eustache 2005-04-27 12:14:56 PDT
                                                 Re: [propel] setByName hlellelid Hans Lellelid 2005-04-27 12:28:52 PDT
                                                     RE: [propel] setByName =?iso-8859-1?Q?David_Z=FClke?= <dz at bitxtender dot com> =?iso-8859-1?Q?David_Z=FClke?= <dz at bitxtender dot com> 2005-04-29 10:03:37 PDT
                                             Re: [propel] more on propel, forms, arrays tony_bibbs Tony Bibbs 2005-04-27 12:43:29 PDT
Messages per page: