当前位置: 首页>>代码示例>>PHP>>正文


PHP FormConfigBuilder::isValidName方法代码示例

本文整理汇总了PHP中Symfony\Component\Form\FormConfigBuilder::isValidName方法的典型用法代码示例。如果您正苦于以下问题:PHP FormConfigBuilder::isValidName方法的具体用法?PHP FormConfigBuilder::isValidName怎么用?PHP FormConfigBuilder::isValidName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Form\FormConfigBuilder的用法示例。


在下文中一共展示了FormConfigBuilder::isValidName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addChoice

 /**
  * Adds a new choice.
  *
  * @param array  $bucketForPreferred The bucket where to store the preferred
  *                                   view objects.
  * @param array  $bucketForRemaining The bucket where to store the
  *                                   non-preferred view objects.
  * @param mixed  $choice             The choice to add.
  * @param string $label              The label for the choice.
  * @param array  $preferredChoices   The preferred choices.
  *
  * @throws InvalidConfigurationException If no valid value or index could be created.
  */
 protected function addChoice(array &$bucketForPreferred, array &$bucketForRemaining, $choice, $label, array $preferredChoices, $level = 0)
 {
     $index = $this->createIndex($choice);
     if ('' === $index || null === $index || !FormConfigBuilder::isValidName((string) $index)) {
         throw new InvalidConfigurationException(sprintf('The index "%s" created by the choice list is invalid. It should be a valid, non-empty Form name.', $index));
     }
     $value = $this->createValue($choice);
     if (!is_string($value)) {
         throw new InvalidConfigurationException(sprintf('The value created by the choice list is of type "%s", but should be a string.', gettype($value)));
     }
     $view = new TreeChoiceView($choice, $value, $label, $level);
     $this->choices[$index] = $this->fixChoice($choice);
     $this->values[$index] = $value;
     if ($this->isPreferred($choice, $preferredChoices)) {
         $bucketForPreferred[$index] = $view;
     } else {
         $bucketForRemaining[$index] = $view;
     }
 }
开发者ID:Charlie-Lucas,项目名称:InfiniteFormBundle,代码行数:32,代码来源:TreeChoiceList.php

示例2: getFormName

 /**
  * Get form name
  *
  * @return string
  */
 public function getFormName()
 {
     if (FormConfigBuilder::isValidName($this->exposedName)) {
         return $this->exposedName;
     }
     $name = $this->exposedName;
     $name = preg_replace('/[^a-zA-Z0-9_]/', '', $name);
     $name = preg_replace('/[^a-zA-Z0-9_\\-:]/', '', $name);
     return $name === '' ? $this->fieldName : $name;
 }
开发者ID:alebon,项目名称:graviton,代码行数:15,代码来源:AbstractField.php

示例3: addTerms

 protected function addTerms(Terms $terms)
 {
     $index = $this->createIndex($terms);
     if ('' === $index || null === $index || !FormConfigBuilder::isValidName((string) $index)) {
         throw new InvalidConfigurationException(sprintf('The index "%s" created by the choice list is invalid. It should be a valid, non-empty Form name.', $index));
     }
     $value = $this->createValue($terms);
     $label = $this->createLabel($terms);
     $view = new ChoiceView($terms, $value, $label);
     $this->choices[$index] = $terms;
     $this->values[$index] = $value;
     if ($terms->isFinal()) {
         $this->final[$index] = $view;
     } else {
         $this->drafts[$index] = $view;
     }
 }
开发者ID:coopers-peele,项目名称:CPTermsBundle,代码行数:17,代码来源:TermsChoiceList.php


注:本文中的Symfony\Component\Form\FormConfigBuilder::isValidName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。