hash table suggestion

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
uptoeleven
Forum Members
Forum Members
Posts: 96
Joined: Sat Dec 04, 2004 10:30 pm
Location: London, England

hash table suggestion

Post by uptoeleven »

Hi,

I'm building an ecommerce site with configurable Products using a multiple-page FormBuilder and lots of Module Interface fields.

Inevitably there is a disconnect between the form and what forms can do, and the Products and what products can do. For example, FormBuilder might want to see form items like this:

<input type="radio" name="cntnt01fbrp__68" value="A product::productId=4" id="cntnt01fbrp__68_1_6" productId="4" />
<label for="cntnt01fbrp__68_1_6">A particular product</label>
<div id="details_4" ><p>A product from my product database, the ID of the product is "4" according to the Products module.</p></div>

Here is the issue - there is no link between what the formbuilder uses and what the Product uses. This is absolutely as it should be from an Object Oriented perspective but in order to manipulate the data derived from this form, I'm having to use insane levels of reflectivity, which is inefficient.

Formbuilder has the form field as cntnt01fbrp__68 and this particular item as cntnt01fbrp__68_1_6.

Products has the item as "4".

Hard-coding the link between productId=4 and formbuilderID=cntnt01fbrp__68_1_6 is a "bad thing" in case I change the form, change the product, or do any number of other alterations that would require all hard-coded links to be rebuilt.

But...

It would be great if there was a module or a tag or a library or something that would generate a hash table based on "current form / product" configuration. It would also be great if that library would then expose a version of this hashtable to javascript. This would be vital for front-end validation where - for example - it is mandatory to select either one of the radio buttons for ProductID=4 OR two of the radio buttons of ProductID=5 and ProductID=6. Without this I have to manipulate FormBuilder to return an "invalid" response to server-side form validation and it's not easy setting "current page" in formbuilder multipage forms to an arbitrary number.

Would the best place to implement this hash table be in CGExtensions? We could make FormBuilder dependent on CGE (Products already are) and then use the hash table to just maintain the dynamic record of which form elements use which products... or does it make the two (3 I guess) modules too interdependent?
Post Reply

Return to “Developers Discussion”