[PHPTAL] PHPTAL and form macros

2010-08-02 Thread Richard Dyce
Hi, Just a pre-re-invent-the-wheel inquiry... Does anyone have an example of macros for formatting form fields in phptal? I have an older framework which create field objects based on the data and type, and populates them from a simple array: e.g. ?php $fields = array( 'id'=

AW: [PHPTAL] PHPTAL and form macros

2010-08-02 Thread Per Bernhardt
Hi, Speaking in terms of MVC your $fields array is a model of a form. It is indeed a model that relatively closely describes, what you want to output in html, but nevertheless it is a model. So what you want to do is to iterate over this model and render it: form div tal:repeat=field

Re: AW: [PHPTAL] PHPTAL and form macros

2010-08-02 Thread Richard Dyce
Per, That's a great help. Yes, the model is massively simplified, but I figured it was better to explain what I was getting at... I take your point about ugliness! On 2 Aug 2010, at 20:20, Per Bernhardt wrote: So keep improving your model! By the way: You should always prefer strong

AW: AW: [PHPTAL] PHPTAL and form macros

2010-08-02 Thread Per Bernhardt
The simple advantage of objects is, that they are not only data but also logic that can operate on this data. In our example this logic could simply be to check, if an option is selected. Although this example is very simple, comparing to values on their equalance is logic. Imagine you would