[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[jfw] How to implement Object/Form in Joomla Framework



Hi everyone,

I am starting some work on a Joomla module that will allow a customer of us (a union) show information about it's members. I don't have much experience with the Joomla Framework but I do have some experience with other frameworks.

However, I'm a little unsure in how to implement the object structure in Joomla. Usually I create my own very basic Model class from which each object inherits a save() and a remove() function and the object is created by a factory. The properties (like username, email address, province, etc) are regular protected properties and they can be accessed by getters and setters.

Now that you know where I'm coming from, I'm very interested how you would implement the following. 
- The member objects have a set of pre-defined properties and I want to be able to add properties without breaking the existing data. (I'm not worried that adding some fields means an update to the current module).
- I want to be able to create a form from each object so each property (or at least most of them) needs to be able to generate a form field. Some are text fields (like Company name), others are one or more of a set of available options (like Province or Interests). I should also be able to create a custom field type (like a map of the country to select a region). 
- The data needs to be stored in the database. That could be in a pre-defined table with each field corresponding to a column or a table with columns like 'member', 'key' and 'value'.
- The member overview page needs to be able to filter the members by it's properties (like all members in a specific province that have these interests).

I hope I explained my idea. I am unsure how to do this in Joomla but I'm guessing the keywords are Joomla\Form, Joomla\Form\Field and Joomla\Model. Should I extend my Member class from Joomla\Form and then have a class Member\Field that extends from Joomla\Form\Field? Or should I extend from Joomla\Model and have a function like createForm() that returns a Joomla\Form? In that case, how would you add the fields? I know the fields need to be instance of SimpleXMLElement so would you store the field configuration in XML? 

I'm very interested in your ideas, I'm not necessarily looking for concrete code fragments but some pseudo code or pointers towards classes or documentation would be awesome. If anything is unclear, please let me know, english is not my first language and I'm in the very beginning of the design of this module.

Thank you in advance!

Greetings,
Henk te Sligte

--
Framework source code: https://github.com/joomla/joomla-framework
Visit http://developer.joomla.org for more information about developing with Joomla!
---
You received this message because you are subscribed to the Google Groups "Joomla! Framework Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-framework+unsubscribe AT googlegroups.com.
Visit this group at http://groups.google.com/group/joomla-dev-framework.