本文整理匯總了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);
}
}