本文整理汇总了PHP中GridField::setForm方法的典型用法代码示例。如果您正苦于以下问题:PHP GridField::setForm方法的具体用法?PHP GridField::setForm怎么用?PHP GridField::setForm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GridField
的用法示例。
在下文中一共展示了GridField::setForm方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setForm
/**
* Set the container form. If the list is an instance of StatefulGridFieldList and the state is empty it tries to restore the state from the session.
* @param {Form} $form Form to be used
*/
public function setForm($form)
{
$return = parent::setForm($form);
if ($this->list instanceof StatefulGridFieldList) {
$stateValue = $this->state->getData()->toArray();
if (empty($stateValue) && !empty($this->form)) {
$this->state->restoreFromSession();
}
}
return $return;
}
开发者ID:helpfulrobot,项目名称:webbuilders-group-silverstripe-statefulunsavedlist,代码行数:15,代码来源:StatefulGridField.php
示例2: testRenderHeaders
/**
* Tests that the appropriate sortable headers are generated
*/
public function testRenderHeaders()
{
// Generate sortable header and extract HTML
$list = new DataList('GridFieldSortableHeaderTest_Team');
$config = new GridFieldConfig_RecordEditor();
$form = new Form(Controller::curr(), 'Form', new FieldList(), new FieldList());
$gridField = new GridField('testfield', 'testfield', $list, $config);
$gridField->setForm($form);
$compontent = $gridField->getConfig()->getComponentByType('GridFieldSortableHeader');
$htmlFragment = $compontent->getHTMLFragments($gridField);
// Check that the output shows name and hat as sortable fields, but not city
$this->assertContains('<span class="non-sortable">City</span>', $htmlFragment['header']);
$this->assertContains('value="Name" class="action ss-gridfield-sort" id="action_SetOrderName"', $htmlFragment['header']);
$this->assertContains('value="Cheerleader Hat" class="action ss-gridfield-sort" id="action_SetOrderCheerleader-Hat-Colour"', $htmlFragment['header']);
// Check inverse of above
$this->assertNotContains('value="City" class="action ss-gridfield-sort" id="action_SetOrderCity"', $htmlFragment['header']);
$this->assertNotContains('<span class="non-sortable">Name</span>', $htmlFragment['header']);
$this->assertNotContains('<span class="non-sortable">Cheerleader Hat</span>', $htmlFragment['header']);
}
示例3: getEditForm
public function getEditForm($id = null, $fields = null)
{
$form = parent::getEditForm($id, $fields);
$filter = $this->jobQueue->getJobListFilter(null, 300);
$list = DataList::create('QueuedJobDescriptor');
$list = $list->where($filter);
$grid = new GridField('QueuedJobDescriptor', _t('QueuedJobs.JobsFieldTitle', 'Jobs'), $list);
$grid->setForm($form);
$form->Fields()->replaceField('QueuedJobDescriptor', $grid);
$grid->getConfig()->addComponent(new GridFieldQueuedJobExecute());
$grid->getConfig()->addComponent(new GridFieldQueuedJobExecute('pause', function ($record) {
return $record->JobStatus == QueuedJob::STATUS_WAIT || $record->JobStatus == QueuedJob::STATUS_RUN;
}));
$grid->getConfig()->addComponent(new GridFieldQueuedJobExecute('resume', function ($record) {
return $record->JobStatus == QueuedJob::STATUS_PAUSED || $record->JobStatus == QueuedJob::STATUS_BROKEN;
}));
$grid->getConfig()->addComponent(new GridFieldDeleteAction());
$formatting = array('Messages' => function ($val, $obj) {
return "<div style='max-width: 300px; max-height: 200px; overflow: auto;'>{$obj->Messages}</div>";
});
$grid->getConfig()->getComponentByType('GridFieldDataColumns')->setFieldFormatting($formatting);
return $form;
}
示例4: getEditForm
/**
* @param int $id
* @param FieldList $fields
* @return Form
*/
public function getEditForm($id = null, $fields = null)
{
$form = parent::getEditForm($id, $fields);
$filter = $this->jobQueue->getJobListFilter(null, 300);
$list = DataList::create('QueuedJobDescriptor');
$list = $list->where($filter)->sort('Created', 'DESC');
$gridFieldConfig = GridFieldConfig_RecordEditor::create()->addComponent(new GridFieldQueuedJobExecute('execute'))->addComponent(new GridFieldQueuedJobExecute('pause', function ($record) {
return $record->JobStatus == QueuedJob::STATUS_WAIT || $record->JobStatus == QueuedJob::STATUS_RUN;
}))->addComponent(new GridFieldQueuedJobExecute('resume', function ($record) {
return $record->JobStatus == QueuedJob::STATUS_PAUSED || $record->JobStatus == QueuedJob::STATUS_BROKEN;
}))->removeComponentsByType('GridFieldAddNewButton');
// Set messages to HTML display format
$formatting = array('Messages' => function ($val, $obj) {
return "<div style='max-width: 300px; max-height: 200px; overflow: auto;'>{$obj->Messages}</div>";
});
$gridFieldConfig->getComponentByType('GridFieldDataColumns')->setFieldFormatting($formatting);
// Replace gridfield
$grid = new GridField('QueuedJobDescriptor', _t('QueuedJobs.JobsFieldTitle', 'Jobs'), $list, $gridFieldConfig);
$grid->setForm($form);
$form->Fields()->replaceField('QueuedJobDescriptor', $grid);
if (Permission::check('ADMIN')) {
$types = ClassInfo::subclassesFor('AbstractQueuedJob');
$types = array_combine($types, $types);
unset($types['AbstractQueuedJob']);
$jobType = DropdownField::create('JobType', _t('QueuedJobs.CREATE_JOB_TYPE', 'Create job of type'), $types);
$jobType->setEmptyString('(select job to create)');
$form->Fields()->push($jobType);
$jobParams = MultiValueTextField::create('JobParams', _t('QueuedJobs.JOB_TYPE_PARAMS', 'Constructor parameters for job creation'));
$form->Fields()->push($jobParams);
$form->Fields()->push($dt = DatetimeField::create('JobStart', _t('QueuedJobs.START_JOB_TIME', 'Start job at')));
$dt->getDateField()->setConfig('showcalendar', true);
$actions = $form->Actions();
$actions->push(FormAction::create('createjob', _t('QueuedJobs.CREATE_NEW_JOB', 'Create new job')));
}
$this->extend('updateEditForm', $form);
return $form;
}