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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Form Questions /

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

What does updateFrontEndFields(...) do?


Go to End


5 Posts   1204 Views

Avatar
vwd

Community Member, 166 Posts

31 October 2011 at 4:14pm

Edited: 31/10/2011 5:40pm

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.

Avatar
Willr

Forum Moderator, 5523 Posts

31 October 2011 at 8:09pm

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.

Avatar
vwd

Community Member, 166 Posts

31 October 2011 at 9:12pm

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.

Avatar
ajshort

Community Member, 244 Posts

31 October 2011 at 9:22pm

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.

Avatar
vwd

Community Member, 166 Posts

1 November 2011 at 1:29am

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