本文整理汇总了PHP中Symfony\Component\Form\FormInterface::getParent方法的典型用法代码示例。如果您正苦于以下问题:PHP FormInterface::getParent方法的具体用法?PHP FormInterface::getParent怎么用?PHP FormInterface::getParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Form\FormInterface
的用法示例。
在下文中一共展示了FormInterface::getParent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildView
/**
* {@inheritdoc}
*/
public function buildView(FormView $view, FormInterface $form, array $options)
{
$view->vars['object'] = $form->getParent()->getData();
if ($options['download_link'] && $view->vars['object']) {
$view->vars['download_uri'] = $this->storage->resolveUri($form->getParent()->getData(), $form->getName());
}
}
示例2: getErrorFormLabel
/**
* Returns first label for field with error
*
* @param FormInterface $form
* @return array
*/
protected function getErrorFormLabel(FormInterface $form)
{
$vars = $form->createView()->vars;
$label = $vars['label'];
$translationDomain = $vars['translation_domain'];
$result = array('label' => $label, 'domain' => $translationDomain);
if (empty($label)) {
if ($form->getParent() !== null) {
$result = $this->getErrorFormLabel($form->getParent());
}
}
return $result;
}
示例3: chooseGroups
/**
* {@inheritdoc}
*/
public function chooseGroups(FormInterface $form)
{
$dayPhoneData = $form->get('dayPhone')->getData();
$eveningPhoneData = $form->get('eveningPhone')->getData();
$emailData = $form->get('email')->getData();
// All other fields are validated through the Default validation group
$validation_groups = array('Default');
// todo: is there an apprpoach that does not require the sdk models?
/** @var ReferencingApplication $application */
$application = $form->getParent()->getData();
if ($application instanceof ReferencingApplication) {
// If Optimum product, require at least one contact detail must be given
if (19 == $application->getProductId()) {
if (empty($dayPhoneData) && empty($eveningPhoneData) && empty($emailData)) {
$validation_groups[] = 'dayphone';
$validation_groups[] = 'eveningphone';
$validation_groups[] = 'email';
}
}
// If no day phone, enforce evening
if (empty($dayPhoneData)) {
$validation_groups[] = 'eveningphone';
}
// If no evening phone, enforce day
if (empty($eveningPhoneData)) {
if ($k = array_search('eveningphone', $validation_groups)) {
unset($validation_groups[$k]);
}
$validation_groups[] = 'dayphone';
}
return $validation_groups;
}
return array('Default');
}
示例4: finishView
/**
* {@inheritdoc}
*/
public function finishView(FormView $view, FormInterface $form, array $options)
{
$permissionForm = $form->getParent();
if (!$permissionForm) {
return;
}
$permissionsForm = $permissionForm->getParent();
if (!$permissionsForm) {
return;
}
$privilegeForm = $permissionsForm->getParent();
if (!$privilegeForm) {
return;
}
$privilegesForm = $privilegeForm->getParent();
if (!$privilegesForm) {
return;
}
$roleForm = $privilegesForm->getParent();
if (!$roleForm) {
return;
}
if (in_array($roleForm->getConfig()->getType()->getName(), [AccountUserRoleType::NAME, FrontendAccountUserRoleType::NAME])) {
//uses on edit page for rendering preloaded string (role permission name)
$view->vars['translation_prefix'] = $this->roleTranslationPrefixResolver->getPrefix();
}
}
示例5: buildView
/**
* {@inheritdoc}
*/
public function buildView(FormView $view, FormInterface $form, array $options)
{
$vars = ['configs' => $options['configs']];
if ($form->getData()) {
$data = $form->getParent()->getData();
$fieldConfig = $this->cm->getProvider('extend')->getConfig($data, $form->getName());
if ($form->getData()) {
/** @var ConverterInterface|EntitySelectHandler $converter */
$converter = $options['converter'];
$result = [];
if ($converter instanceof EntitySelectHandler) {
$converter->initForEntity($fieldConfig->getId()->getClassName(), $fieldConfig->get('target_field'));
}
if (isset($options['configs']['multiple']) && $options['configs']['multiple']) {
foreach ($form->getData() as $item) {
$result[] = $converter->convertItem($item);
}
} else {
$result[] = $converter->convertItem($form->getData());
}
$vars['attr'] = ['data-selected-data' => json_encode($result)];
}
}
$view->vars = array_replace_recursive($view->vars, $vars);
}
示例6: finishView
/**
* {@inheritDoc}
*/
public function finishView(FormView $view, FormInterface $form, array $options)
{
$formParent = $form->getParent();
if (!$formParent) {
return;
}
/* @var $productUnitHolder ProductUnitHolderInterface */
$productUnitHolder = $formParent->getData();
if (!$productUnitHolder) {
return;
}
$product = $productUnitHolder->getProductHolder()->getProduct();
$choices = $this->getProductUnits($product);
$productUnit = $productUnitHolder->getProductUnit();
if (!$productUnit || $product && !in_array($productUnit, $choices, true)) {
$emptyValueTitle = $this->translator->trans($this->options['empty_label'], ['{title}' => $productUnitHolder->getProductUnitCode()]);
$view->vars['empty_value'] = $emptyValueTitle;
}
$choices = $this->productUnitFormatter->formatChoices($choices, $options['compact']);
$choicesViews = [];
foreach ($choices as $key => $value) {
$choicesViews[] = new ChoiceView($value, $key, $value);
}
$view->vars['choices'] = $choicesViews;
}
示例7: getRootFormCascadeOption
/**
* Navigates to the Root form to define if cascading should be done.
*
* @param FormInterface $form
* @return boolean
*/
public function getRootFormCascadeOption(FormInterface $form)
{
if (!$form->isRoot()) {
return $this->getRootFormCascadeOption($form->getParent());
}
return $form->getConfig()->getOption('cascade_filter', false);
}
示例8: buildView
/**
* Pass the image URL to the view.
*
* @param FormView $view
* @param FormInterface $form
* @param array $options
*/
public function buildView(FormView $view, FormInterface $form, array $options)
{
$data = $form->getParent()->getData();
if ($data instanceof ContentSpec) {
$tmpName = explode('_', $form->getName());
if (count($tmpName) === 3) {
$currentFile = null;
foreach ($data->getTranslations() as $tr) {
if ($tr->getLocale() == $tmpName[1] && ($tr->getField() == 'content' || $tr->getField() == 'data')) {
$contents = json_decode($tr->getContent(), true);
if (isset($contents[$tmpName[2]])) {
$currentFile = $contents[$tmpName[2]];
}
}
}
} else {
$currentFile = $data->getInContent($form->getName());
if (!$currentFile) {
$currentFile = $data->getInData($form->getName());
}
}
if ($currentFile) {
$currentFileWeb = $this->nyrocms->getHandler($data->getContentHandler())->getUploadDir() . '/' . $currentFile;
$view->vars['currentFile'] = $currentFileWeb;
$view->vars['showDelete'] = $options['showDelete'] && is_string($options['showDelete']) ? $options['showDelete'] : false;
}
}
}
示例9: disableField
/**
* Disable a field after the form has been created
*
* @param FormInterface $field
*/
protected function disableField(FormInterface $field)
{
$config = $field->getConfig();
$options = $config->getOptions();
$options['disabled'] = true;
$field->getParent()->add($field->getName(), $config->getType()->getInnerType(), $options);
}
示例10: buildView
public function buildView(FormView $view, FormInterface $form, array $options)
{
//parent::buildView($view, $form, $options);
$entity = $form->getParent()->getData();
$property_name = $view->vars['name'];
$this->defaults = array_merge($this->defaults, $options);
// entity info
$entity_info = $this->container->get('itf.admin_helper')->getEntityInfo(get_class($entity));
$fk_entity_info = $this->container->get('itf.admin_helper')->getEntityInfo($this->defaults['data_class']);
$this->defaults['fn_entity'] = $entity_info['entity_short'];
$this->defaults['fn_bundle'] = $entity_info['bundle_short'];
$this->defaults['fn_property'] = $property_name;
$this->defaults['fn_fk_entity'] = $fk_entity_info['entity_short'];
$this->defaults['fn_fk_bundle'] = $fk_entity_info['bundle_short'];
// extract constraints
$validator = $this->container->get('validator');
$metadata = $validator->getMetadataFor($fk_entity_info['entity_fq']);
if (isset($metadata->properties[$this->defaults['fn_entity_property']])) {
$this->extractConstraints($metadata->properties[$this->defaults['fn_entity_property']]);
}
// set id
if (method_exists($entity, 'getId')) {
$this->defaults['fn_entity_id'] = (int) $entity->getId();
}
$view->vars = array_merge($view->vars, $this->defaults);
}
示例11: finishView
/**
* {@inheritdoc}
*/
public function finishView(FormView $view, FormInterface $form, array $options)
{
$permissionForm = $form->getParent();
if (!$permissionForm) {
return;
}
$permissionsForm = $permissionForm->getParent();
if (!$permissionsForm) {
return;
}
$privilegeForm = $permissionsForm->getParent();
if (!$privilegeForm) {
return;
}
$privilegesForm = $privilegeForm->getParent();
if (!$privilegesForm) {
return;
}
$roleForm = $privilegesForm->getParent();
if (!$roleForm) {
return;
}
if ($roleForm->getConfig()->getType()->getName() === AccountUserRoleType::NAME) {
$view->vars['translation_prefix'] = 'orob2b.customer.security.access-level.';
}
}
示例12: buildView
public function buildView(FormView $view, FormInterface $form, array $options)
{
$options['expanded'] = false;
// only select can be dynamic
if ($options['source_field']) {
$value = $form->getParent()[$options['source_field']]->getData();
if (is_object($value)) {
$value = $value->getId();
}
$view->vars['source_field'] = $options['source_field'];
$completeChoices = array();
foreach ($options['choices'] as $key => $val) {
$completeChoices[$key] = array();
foreach ($val as $k => $v) {
$completeChoices[$key][] = array('id' => $k, 'text' => $v);
}
}
$view->vars['complete_choices'] = $completeChoices;
$choices = array();
if (isset($options['choices'][$value])) {
$choices = $options['choices'][$value];
}
$options['choice_list'] = new SimpleChoiceList($choices);
}
parent::buildView($view, $form, $options);
}
示例13: buildView
/**
* {@inheritdoc}
*/
public function buildView(FormView $view, FormInterface $form, array $options)
{
$parentData = $form->getParent()->getData();
$accountId = null;
if ($parentData instanceof Account) {
$accountId = $parentData->getId();
}
$view->vars['configs']['accountId'] = $accountId;
}
示例14: buildView
/**
* {@inheritdoc}
*/
public function buildView(FormView $view, FormInterface $form, array $options)
{
$parentData = $form->getParent()->getData();
$parentId = null;
if ($parentData instanceof Customer) {
$parentId = $parentData->getId();
}
$view->vars['parent_id'] = $parentId;
}
示例15: buildView
/**
* {@inheritdoc}
*/
public function buildView(FormView $view, FormInterface $form, array $options)
{
$parent = $form->getParent()->getParent()->getParent();
$parentData = $parent->getData();
if ($parentData instanceof AclPrivilege) {
$view->vars['identity'] = $parentData->getIdentity()->getId();
$view->vars['level_label'] = AccessLevel::getAccessLevelName($form->getData());
}
}