I posted this question in other Customizing CMS forum, with no response since I'm actually using the DataObjectManager I thought I'd post here.
I'm using the DataObjectManager to Create a User Application Form. I want to Add a Buttons to the Pop-Up that Either Delete the Application or Approve it, thus copying the Data to a member group.
Here is my UserApplication DataObject
class UserApplication extends DataObject {
static $db = array(
'FirstName' => 'Text',
'LastName' => 'Text',
'Email' => 'Text',
'CompanyName' => 'Text',
'CompanyType' => "Text",
'CompanyURL' => 'Text',
'CompanyPhone' => 'Text',
'Address' => 'Text',
'Address2' => 'Text',
'City' => 'Text',
'Country' => 'Text',
'TaxIDNumber' => 'Text',
'Distributor' => 'Text',
'SalesRep' => 'Text',
'Description' => 'Text',
'ApprovedMember' => 'Boolean',
'Password' => 'Text'
);
static $has_one = array(
'RegistrationPage' => 'RegistrationPage',
);
public function getCMSFields_forPopup()
{
$companyTypeList = array(
'Retail' => 'Retail',
'Online' => 'Online',
'Distributor' => 'Distributor',
'Press' => 'Press'
);
return new FieldSet (
new CheckBoxField('ApprovedMember', 'Approved Member'),
new TextField('FirstName', 'First Name'),
new TextField('LastName','Last Name'),
new EmailField('Email'),
new TextField('CompanyName','Company Name'),
new DropdownField('CompanyType','Company Type',$companyTypeList),
new TextField('CompanyURL','Company Website'),
new TextField('CompanyPhone','CompanyPhone'),
new TextField('Address','Address'),
new TextField('Address2','Address Line 2'),
new TextField('City','City'),
new TextField('Country','Country'),
new TextField('TaxIDNumber','TaxIDNumber'),
new TextField('Distributor','Distributor'),
new TextField('SalesRep','Sales Rep'),
new TextareaField('Description','Description'),
new ConfirmedPasswordField('Password')
);
}
}
And This is my Registration Page, I still need to create a a front end Form Element for End Users to Fill in.
class RegistrationPage extends Page
{
static $has_many = array (
'UserApplications' => 'UserApplication'
);
public function getCMSFields()
{
$f = parent::getCMSFields();
$applicationManager = new DataObjectManager(
$this,
'UserApplications',
'UserApplication',
array('FirstName' => 'FirstName','LastName' => 'LastName','Email' => 'Email','CompanyName' => 'CompanyName','CompanyType' => "CompanyType",'CompanyURL' => 'CompanyURL','CompanyPhone' => 'CompanyPhone','Address' => 'Address','Address2' => 'Address2','City' => 'City','Country' => 'Country','TaxIDNumber' => 'TaxIDNumber','Distributor' => 'Distributor','SalesRep' => 'SalesRep','Description' => 'Description','ApprovedMember' => 'ApprovedMember','Password' => 'Password'),
'getCMSFields_forPopup'
);
$f->addFieldToTab("Root.Content.Applications", $applicationManager);
$f->removeFieldFromTab('Root.Content.Main', 'Content');
$f->removeFieldFromTab('Root.Content.Main', 'LifestyleText');
return $f;
}
}
class RegistrationPage_Controller extends Page_Controller
{
}
Would I use a standard form $actions in the DataObject FieldSet.
Incidentally, does the DataObjectManager not have a Delete like the FileDataObjectManager?
I really can't wait until the SilverStripe Book comes out LOL