Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Data Model Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Accessing DataObject fields in front-end form

Go to End



Community Member, 6 Posts

26 October 2012 at 11:09pm

Hi guys :)

I question I've poured over the forums to try and find a resolution but I'm still stuck :/

I'm running the DataObjectAsPage module for products on a website and I'm trying to integrate enquiry forms that are specific to each product.
In order to do this, I need to pull through data fields from the product as hidden fields within the form. However...

As this requires a <% control Item %> loop I have the usual conflict between Model and Controller and I'm looping between the two below:

a) If I place the form functions in the Item.php DataObject, the form will display with the necessary hidden fields - but the form processing functions do not work. Even if these functions are stored within the DataObject or the DataObjectListingPage.

b) If I place the form functions in the DataObjectListingPage, then the form will process as required but the Controller cannot access the DataObject data to populate the hidden fields. I have tried using various <% if %>, <% if Top.* %> and <% control %> statements but to no avail....

I'm guessing I need to create a custom controller for the DataObject??
Will this work and if so, does anyone know the best way of completing it??

Thanks in anticipation