本文整理汇总了PHP中FormField::setSource方法的典型用法代码示例。如果您正苦于以下问题:PHP FormField::setSource方法的具体用法?PHP FormField::setSource怎么用?PHP FormField::setSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FormField
的用法示例。
在下文中一共展示了FormField::setSource方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($name, $title = null, $value = "")
{
// naming with underscores to prevent values from actually being saved somewhere
$this->fieldType = new OptionsetField("{$name}[Type]", _t('HtmlEditorField.LINKTO', 'Link to'), array('Internal' => _t('HtmlEditorField.LINKINTERNAL', 'Page on the site'), 'External' => _t('HtmlEditorField.LINKEXTERNAL', 'Another website'), 'Email' => _t('HtmlEditorField.LINKEMAIL', 'Email address'), 'File' => _t('HtmlEditorField.LINKFILE', 'Download a file')), 'Internal');
$this->fieldLink = new CompositeField($this->internalField = WTTreeDropdownField::create("{$name}[Internal]", _t('HtmlEditorField.Internal', 'Internal'), 'SiteTree', 'ID', 'Title', true), $this->externalField = TextField::create("{$name}[External]", _t('HtmlEditorField.URL', 'URL'), 'http://'), $this->emailField = EmailField::create("{$name}[Email]", _t('HtmlEditorField.EMAIL', 'Email address')), $this->fileField = WTTreeDropdownField::create("{$name}[File]", _t('HtmlEditorField.FILE', 'File'), 'File', 'ID', 'Title', true), $this->extraField = TextField::create("{$name}[Extra]", 'Extra(optional)')->setDescription('Appended to url. Use to add sub-urls/actions or query string to the url, e.g. ?param=value'), $this->anchorField = TextField::create("{$name}[Anchor]", 'Anchor (optional)'), $this->targetBlankField = CheckboxField::create("{$name}[TargetBlank]", _t('HtmlEditorField.LINKOPENNEWWIN', 'Open link in a new window?')));
if ($linkableDataObjects = WTLink::get_data_object_types()) {
if (!($objects = self::$linkable_data_objects)) {
$objects = array();
foreach ($linkableDataObjects as $className) {
$classObjects = array();
//set the format for DO value -> ClassName-ID
foreach (DataList::create($className) as $object) {
$classObjects[$className . '-' . $object->ID] = $object->Title;
}
if (!empty($classObjects)) {
$objects[singleton($className)->i18n_singular_name()] = $classObjects;
}
}
}
if (count($objects)) {
$this->fieldType->setSource(array_merge($this->fieldType->getSource(), array('DataObject' => _t('WTLinkField.LINKDATAOBJECT', 'Data Object'))));
$this->fieldLink->insertBefore("{$name}[Extra]", $this->dataObjectField = GroupedDropdownField::create("{$name}[DataObject]", _t('WTLinkField.LINKDATAOBJECT', 'Link to a Data Object'), $objects));
}
self::$linkable_data_objects = $objects;
}
$this->extraField->addExtraClass('no-hide');
$this->anchorField->addExtraClass('no-hide');
$this->targetBlankField->addExtraClass('no-hide');
parent::__construct($name, $title, $value);
}