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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Does anybody know how to iterate DataObject::database_fields

Go to End

3 Posts   962 Views


Community Member, 25 Posts

10 April 2012 at 6:05pm

What I'm trying to do is to traverse all the elements within this static field arrays of Dataobject and have it prepopulated in a dropdown box.

How do I accomplish this as part of an extension to UDF module's functionality.


Forum Moderator, 5523 Posts

11 April 2012 at 7:12pm

So this is a dropdown the user of the site can select a field from? You'll want to create your own subclass of EditableFormField and override the getFormField() to return your dropdown field populated with the fields. DataObject::database_fields() simply returns a map of names to types so if you want your dropdown to have keys and values of the field name you could do something like following quite easy..

$options = array();
foreach(DataObject::database_fields('Page') as $key => $type) $options[$key] = $key;

return new DropdownField(.., ..., $options);

Have a look at how the other editable form fields work, if you subclass EditableFormField and put your class in the mysite folder SS will automatically pick up the new form field type in the UDF create options.


Community Member, 25 Posts

14 April 2012 at 1:19am

Pretty much!

With one minor difference - these fields would be used by the CMS administrator, not the web user.

If you ever program VB Access in the old days, you know how every data controls that gets bound by certain data source's record source's properties? In every VB form, you can bind the whole form to an entire table, along with its data controls to their corresponding fields?

That's what I'm trying to here in SS! I want to reproduce that similar experience here in UDF for those UDF's input fields.

I'm very curious how we can port this aspect of VBA's IDE within SS environment...?