<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet title="XSL formatting" type="text/xsl" href="http://blog.invenzzia.org/en/feed/rss2/xslt" ?><rss version="2.0"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:wfw="http://wellformedweb.org/CommentAPI/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
  <title>Invenzzia... in English - Open Power Forms</title>
  <link>http://blog.invenzzia.org/en/</link>
  <description></description>
  <language>en</language>
  <pubDate>Fri, 25 Jul 2008 17:12:15 +0100</pubDate>
  <copyright>Copyright &amp;copy; Invenzzia</copyright>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Dotclear</generator>
  
    
  <item>
    <title>Deeper processing</title>
    <link>http://blog.invenzzia.org/en/post/Deeper-processing</link>
    <guid isPermaLink="false">urn:md5:d6abe77b1e5105e2840bb0cc54643046</guid>
    <pubDate>Thu, 31 Jan 2008 13:42:00 +0100</pubDate>
    <dc:creator>Zyx</dc:creator>
        <category>Open Power Template</category>
        <category>Open Power Forms</category>    
    <description>&lt;p&gt;The last project I've created using Open Power Forms, shown some weaknesses of the current form implementation. There were some forms allowing a mass addition of many records in the following way: a table, in the columns the following fields: Name, Surname, PESEL number, etc. The numer of rows was 30, so the user is able to add 30 people to the database with one form. The adaptation of the &lt;em&gt;map()&lt;/em&gt; method to my problem was not too hard; in fact it seemed that &lt;em&gt;opfArrayContainer&lt;/em&gt; solved everything. But then the form renderer connected with Open Power Template went off.&lt;/p&gt;    &lt;p&gt;My code looked like that:&lt;/p&gt;

&lt;pre name=&quot;code&quot; class=&quot;php&quot;&gt;$this -&amp;gt; map('names', new opfArrayContainer(
	new opfConstraint(MAP_TYPE, TYPE_STRING),
	new opfConstraint(MAP_LEN_GT, 2)
), OPF_OPTIONAL);
$this -&amp;gt; map('surnames', new opfArrayContainer(
	new opfConstraint(MAP_TYPE, TYPE_STRING),
	new opfConstraint(MAP_LEN_GT, 2)
), OPF_OPTIONAL);
$this -&amp;gt; map('pesels', new opfArrayContainer(
	new sConstraint(MAP_PESEL)
), OPF_OPTIONAL);
&lt;/pre&gt;


&lt;p&gt;In other words, the script must have received for example the &quot;names&quot; field, which was an array of 30 elements with the names. If the user made a mistake while filling in the form, the form renderer did not have a clue, which component to display as invalid (in this case it should be colored red instead of green). Finally, I added a support for the &lt;em&gt;IGNORE_OPF_ERRORS&lt;/em&gt; constant so that shut it up and just display everything without all this color rotation stuff.&lt;/p&gt;


&lt;p&gt;Of course, it is not possible to keep this problem unsolved in the &quot;public&quot; releases and I decided to look for solution. It would be nice, if the improvement easily matched to the code, as well as was intuitive. It's not a problem to add something in 20 minut and a month later self-wishing a rapid death. The best solutions are simple and effective, so I started to think, how to describe a form with some definitions and transformations, so that it would be possible to construct every form and process it with OPF. My idea is to go somewhere deeper and remove distinguishing between forms and form elements. The reasons:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Both have a value (in the form case we define it as a set of subelement values).&lt;/li&gt;
&lt;li&gt;Both have a state.&lt;/li&gt;
&lt;li&gt;Both can be processed.&lt;/li&gt;
&lt;/ol&gt;
&lt;pre&gt;&lt;/pre&gt;

&lt;p&gt;Now we can easily treat a form as an element which is capable of storing other fields. If we try to build our form described above, it will look like this: we create a form for a single person: name, surname, PESEL, etc. Next, we put it into a bigger form and order to loop up to 30 times. We can also achieve an effect of looping a single field, like it was possible with &lt;em&gt;opfArrayContainer()&lt;/em&gt; so far. We just put in such loop not a form, but a single element.&lt;/p&gt;


&lt;p&gt;Well, now the problem is, how to render it :). However, I don't think it will be complicated, especially if I look at the new Open Power Template.&lt;/p&gt;</description>
    
    
    
          <comments>http://blog.invenzzia.org/en/post/Deeper-processing#comment-form</comments>
      <wfw:comment>http://blog.invenzzia.org/en/post/Deeper-processing#comment-form</wfw:comment>
      <wfw:commentRss>http://blog.invenzzia.org/en/feed/rss2/comments/3</wfw:commentRss>
      </item>
    
</channel>
</rss>