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.

Form Questions /

How to bind data source on the forms in Silverstripe


Reply


3 Posts   551 Views

Avatar
CMSPlayer

Community Member, 25 Posts

10 April 2012 at 10:22am

As per titular heading, I'm wondering if there's any sample code out there in community that allows me to bind data source on the form's fields?

I'm sure this is a very common task when building any database-driven websites and I'm curious how I can manipulate modules like UDF to save the fields' data into a table?

Avatar
Willr

Forum Moderator, 5513 Posts

11 April 2012 at 7:18pm

You can bind data sources to regular forms quite easily ($form->loadDataFrom($obj); $form->saveInto($obj)) but UDF hasn't been designed to support those sort of options yet.

Some basic hooks [1] are available to developers to add on their own extensions to load without hacking core but at the moment support for custom actions is minor.

[1] https://github.com/silverstripe/silverstripe-userforms/blob/master/code/UserDefinedForm.php#L412

If you want to save data you could put an extension and tie into the onAfterWrite function of SubmittedForm.

Avatar
CMSPlayer

Community Member, 25 Posts

17 April 2012 at 10:46am

HI @Willr,

Thanks for the help.

I tried the link below. Got a 404 error.

Can you show me the correct link again?