Jump to:

10850 Posts in 2517 Topics by 1793 members

All other Modules

SilverStripe Forums » All other Modules » Modifying the UserDefinedForm(UDF) Module to suit my needs

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 357 Views
  • CMSPlayer
    Avatar
    Community Member
    25 Posts

    Modifying the UserDefinedForm(UDF) Module to suit my needs Link to this post

    I've been playing a while with the module. I like everything that it offers like drag-and-drop user interfaces, email submissions, etc..

    Now what I want to extend the functionality behind this so that I can have every new editableformfields' values to be saved into DataObject.

    For eg, I have this code here

    function doSubmitRegistration($data, $form){
          $volunteer = new Volunteer();
          
          $volunteer->Title=$form->dataFieldByName('Title')->dataValue();
          $volunteer->Gender=$form->dataFieldByName('Gender')->dataValue();
          $volunteer->FirstName=$form->dataFieldByName('FirstName')->dataValue();
          $volunteer->Surname=$form->dataFieldByName('Surname')->dataValue();
          $volunteer->DateOfBirth=$form->dataFieldByName('DateOfBirth')->dataValue();
          $volunteer->Occupation=$form->dataFieldByName('Occupation')->dataValue();
          $volunteer->ContactType=$form->dataFieldByName('ContactType')->dataValue();
          $volunteer->ContactNo=$form->dataFieldByName('ContactNo')->dataValue();
          $volunteer->Email=$form->dataFieldByName('Email')->dataValue();
          $volunteer->Address=$form->dataFieldByName('Address')->dataValue();
          $volunteer->State=$form->dataFieldByName('State')->dataValue();
          $volunteer->Postcode=$form->dataFieldByName('Postcode')->dataValue();
          $volunteer->MarketingSource=$form->dataFieldByName('MarketingSource')->dataValue();
          $volunteer->MembershipType=$form->dataFieldByName('MembershipType')->dataValue();
          
          $volunteer->write();
          $form->sessionMessage(
             'IVP Volunteer Registraton Form successfully submitted',
             'good'
          );
          Director::redirectBack();
          return;
       }

    This code is uses the FormField - not the formfield from UDF's module. I have a volunteer table, or dataObject in this case.

    I explicitly save all the form's input fields by referencing its dataFieldByName property (and obtaining its data value) and then saved them into my volunteer Dataobject.

    So how do I to accomplish something similar under the UDF's framework? What are accessor methods or classes in the getFieldConfiguration method can I hope to accomplish like this?

    PS: This relates to my previous post: http://www.silverstripe.org/form-questions/show/19647#post313359#post313359

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