本文整理匯總了PHP中Sonata\AdminBundle\Admin\FieldDescriptionInterface::mergeOption方法的典型用法代碼示例。如果您正苦於以下問題:PHP FieldDescriptionInterface::mergeOption方法的具體用法?PHP FieldDescriptionInterface::mergeOption怎麽用?PHP FieldDescriptionInterface::mergeOption使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Sonata\AdminBundle\Admin\FieldDescriptionInterface
的用法示例。
在下文中一共展示了FieldDescriptionInterface::mergeOption方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: addFilter
/**
* @param DatagridInterface $datagrid
* @param string $type
* @param FieldDescriptionInterface $fieldDescription
* @param AdminInterface $admin
*/
public function addFilter(DatagridInterface $datagrid, $type = null, FieldDescriptionInterface $fieldDescription, AdminInterface $admin)
{
if ($type == null) {
$guessType = $this->guesser->guessType($admin->getClass(), $fieldDescription->getName(), $admin->getModelManager());
$type = $guessType->getType();
$fieldDescription->setType($type);
$fieldDescription->mergeOption('field_options', $guessType->getOptions());
} else {
$fieldDescription->setType($type);
}
$this->fixFieldDescription($admin, $fieldDescription);
$admin->addFilterFieldDescription($fieldDescription->getName(), $fieldDescription);
$fieldDescription->mergeOption('field_options', array('required' => false));
$filter = $this->filterFactory->create($fieldDescription->getName(), $type, $fieldDescription->getOptions());
if (false !== $filter->getLabel() && !$filter->getLabel()) {
$filter->setLabel($admin->getLabelTranslatorStrategy()->getLabel($fieldDescription->getName(), 'filter', 'label'));
}
$datagrid->addFilter($filter);
}