PHP code example of bratiask / silverstripe-pickerfield
1. Go to this page and download the library: Download bratiask/silverstripe-pickerfield library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
bratiask / silverstripe-pickerfield example snippets
/***********************
Mock DataObject
************************/
class Dog extends DataObject {
static $db = array(
'Title' => 'Varchar',
// ....
);
static $has_one = array(
'Breeder' => 'Breeder'
'Dam' => 'Dog',
'Sire' => 'Dog',
// ....
);
static $has_many = array(
'Owners' => 'Member',
// ....
);
// ....
}
/***********************
Field Usage
************************/
// sortable field appropriate for selection of has_many and many_many objects
$field = new PickerField('Owners', 'Owners', $this->Owners(), 'Select Owner(s)', 'SortOrder');
// non-sortable version of the above
$field = new PickerField('Owners', 'Owners', $this->Owners());
// sortable field appropriate for the parent selection of a has_one relationship
$field = new HasOnePickerField($this, 'DamID', 'Selected Dam', $this->Dam(), 'Select a Dam');
// we also allow the ability to create and edit associated records via enableCreate, enableEdit methods.
$fields->addFieldsToTab('Root.Main', array(
new HeaderField('Info','Info Blocks'),
$field = new HasOnePickerField($this, 'AboutInfoBlockID', 'About Block', $this->AboutInfoBlock())
));
$field->enableCreate('Add Block')->enableEdit();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.