本文整理汇总了PHP中Symfony\Component\Form\FormInterface::count方法的典型用法代码示例。如果您正苦于以下问题:PHP FormInterface::count方法的具体用法?PHP FormInterface::count怎么用?PHP FormInterface::count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Form\FormInterface
的用法示例。
在下文中一共展示了FormInterface::count方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildViewRootForm
/**
* @test
*/
public function buildViewRootForm()
{
$this->configureFormRoot();
$this->form->count()->shouldBeCalled()->willReturn(2);
$extension = $this->createExtension();
$this->buildView($extension);
$attributes = $this->view->vars['attr'];
$this->assertArrayHasKey('novalidate', $attributes);
$this->assertTrue($attributes['novalidate']);
$this->assertArrayHasKey('data-parsley-validate', $attributes);
$this->assertTrue($attributes['data-parsley-validate']);
$this->assertArrayNotHasKey('data-parsley-trigger', $attributes);
}
示例2: buildView
/**
* {@inheritdoc}
*
* @param FormView $view
* @param FormInterface $form
* @param array $options
*/
public function buildView(FormView $view, FormInterface $form, array $options)
{
if ($form->count() == 0) {
return;
}
array_map(array($this, 'validateButton'), $form->all());
}
示例3: getErrorMessages
/**
* Returns an array with form fields errors
*
* @param FormInterface $form
* @param bool|false $useLabels
* @param array $errors
* @return array
*/
public function getErrorMessages(FormInterface $form, $useLabels = false, $errors = array())
{
if ($form->count() > 0) {
foreach ($form->all() as $child) {
if (!$child->isValid()) {
$errors = $this->getErrorMessages($child, $useLabels, $errors);
}
}
}
foreach ($form->getErrors() as $error) {
if ($useLabels) {
$fieldNameData = $this->getErrorFormLabel($form);
} else {
$fieldNameData = $this->getErrorFormId($form);
}
$fieldName = $fieldNameData;
if ($useLabels) {
/**
* @ignore
*/
$fieldName = $this->translator->trans($fieldNameData['label'], array(), $fieldNameData['domain']);
}
$errors[$fieldName] = $error->getMessage();
}
return $errors;
}
示例4: isExpanded
protected function isExpanded(FormInterface $form)
{
if (0 === $form->count()) {
return false;
}
$innerType = $form->getConfig()->getType()->getInnerType();
if (0 === strpos(get_class($innerType), 'Symfony')) {
return false;
}
return true;
}
示例5: unbind
/**
* Returns the form's data like $form->submit() expects it
*
* @param FormInterface $form
* @return array
*/
protected function unbind(FormInterface $form)
{
if ($form->count() > 0) {
$ary = array();
foreach ($form->all() as $name => $child) {
$value = $this->unbind($child);
if (null !== $value || (is_array($value) || $value instanceof Collection) && count($value) > 0) {
$ary[$name] = $value;
}
}
return $ary;
} else {
$data = $form->getViewData();
return $data instanceof Collection ? $data->toArray() : $data;
}
}
示例6: addChildErrors
private static function addChildErrors(FormInterface $parent, &$errors, $path = '')
{
if ($parent->count() == 0) {
return;
}
foreach ($parent as $child) {
if ($path == '') {
$childPath = $child->getName();
} else {
$childPath = $path . '.' . $child->getName();
}
if ($child->isValid()) {
continue;
}
$childErrors = array();
foreach ($child->getErrors() as $key => $error) {
$childErrors[$key] = $error->getMessage();
}
if (count($childErrors) > 0) {
$errors[$childPath] = $childErrors;
}
self::addChildErrors($child, $errors, $childPath);
}
}