Jump to:

1976 Posts in 1306 Topics by 607 members

Form Questions

SilverStripe Forums » Form Questions » What does updateFrontEndFields(...) do?

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

Page: 1
Go to End
Author Topic: 404 Views
  • vwd
    Avatar
    Community Member
    158 Posts

    What does updateFrontEndFields(...) do? Link to this post

    Hi,

    I have a reasonable idea what updateCMSFields does - updates (ie adds/removes) fields from the CMS.

    According to the comments in updateFrontEndFields() (line 175 of DataDecoratorObject.php) performs a similar method for front end forms.

    But when and how is it used? I'm trying to find some real-word examples that demonstrate its usefulness...

    Eg. Line 36 of Geocodable.php. What is purpose of calling updateCMSFields() here? Having set a breakpoint on this method and debugging an instance using Addressable/Geocodable, it doesn't seem to hit this breakpoint?

    Really appreciate your help.

    Thanks.
    VWD.

  • Willr
    Avatar
    Forum Moderator
    5464 Posts

    Re: What does updateFrontEndFields(...) do? Link to this post

    updateFrontEndFields seems like it was a half baked implementation, all the modules I've seen refer to the front end differently so you'll find your mileage using that will vary. I guess the module is trying to conform to the DataObjectDecorator interface by including support for it. If you want to make your own custom signup form then in the front end you could use it like $fields = $member->getFrontEndFields() which'll pickup all the fields in extensions attached to Member.

  • vwd
    Avatar
    Community Member
    158 Posts

    Re: What does updateFrontEndFields(...) do? Link to this post

    Hi Will,

    Thanks very much for your response.

    I can see how it could be useful.

    In what sense do you reckon it's half-baked though? Is there a more common approach for extending front end forms?

    Thanks again.
    VWD.

  • ajshort
    Avatar
    Community Member
    244 Posts

    Re: What does updateFrontEndFields(...) do? Link to this post

    The getFrontEndFields fields method is actually just a counterpart to the getCMSFields method - just without the tabbed interface and other CMS-centric things. Although it's not used out of the box I personally use it quite extensively when creating forms in the front end. The updateCMSFields and updateFrontEndFields methods are used so extensions can modify the CMS or front end form fields for editing an object. The reason I called one inside the other in this case is because they both do the same thing, and i didn't want to repeat the code.

  • vwd
    Avatar
    Community Member
    158 Posts

    Re: What does updateFrontEndFields(...) do? Link to this post

    @ ajshort, Thanks very much for your response Andrew.

    So you use updateCMSFields/updateFrontEndFields as good practise...

    So in this instance, you didn't want either Lat/Lng to be visible in the CMS or on Front End Forms? But why would you explicitly need to remove them, even though you're not adding them to the CMS/Front End forms at all?

    Thanks for taking the time to explain...

    VWD.

    404 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.