本文整理汇总了PHP中Sonata\AdminBundle\Admin\AdminInterface::getFormFieldDescriptions方法的典型用法代码示例。如果您正苦于以下问题:PHP AdminInterface::getFormFieldDescriptions方法的具体用法?PHP AdminInterface::getFormFieldDescriptions怎么用?PHP AdminInterface::getFormFieldDescriptions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sonata\AdminBundle\Admin\AdminInterface
的用法示例。
在下文中一共展示了AdminInterface::getFormFieldDescriptions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: retrieveFormFieldDescription
/**
* Retrieve the form field description given by field name.
*
* @param AdminInterface $admin
* @param string $field
*
* @return FormInterface
*
* @throws \RuntimeException
*/
private function retrieveFormFieldDescription(AdminInterface $admin, $field)
{
$admin->getFormFieldDescriptions();
$fieldDescription = $admin->getFormFieldDescription($field);
if (!$fieldDescription) {
throw new \RuntimeException(sprintf('The field "%s" does not exist.', $field));
}
if (null === $fieldDescription->getTargetEntity()) {
throw new \RuntimeException(sprintf('No associated entity with field "%s".', $field));
}
return $fieldDescription;
}
示例2: retrieveFieldDescription
/**
* Retrieve the field description given by field name.
*
* @param AdminInterface $admin
* @param string $field
*
* @return \Symfony\Component\Form\FormInterface
*
* @throws \RuntimeException
*/
private function retrieveFieldDescription(AdminInterface $admin, $field)
{
$admin->getFormFieldDescriptions();
$fieldDescription = $admin->getFormFieldDescription($field);
if (!$fieldDescription) {
throw new \RuntimeException(sprintf('The field "%s" does not exist.', $field));
}
if ($fieldDescription->getType() !== 'sonata_type_model_autocomplete') {
throw new \RuntimeException(sprintf('Unsupported form type "%s" for field "%s".', $fieldDescription->getType(), $field));
}
if (null === $fieldDescription->getTargetEntity()) {
throw new \RuntimeException(sprintf('No associated entity with field "%s".', $field));
}
return $fieldDescription;
}