Jump to:

3372 Posts in 998 Topics by 712 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Accessing DataObject fields in front-end form

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

Page: 1
Go to End
Author Topic: 388 Views
  • CloudInfinity
    Avatar
    Community Member
    6 Posts

    Accessing DataObject fields in front-end form Link to this post

    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
    Antony

    388 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.