本文整理汇总了PHP中Symfony\Component\Form\FormView类的典型用法代码示例。如果您正苦于以下问题:PHP FormView类的具体用法?PHP FormView怎么用?PHP FormView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FormView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildView
public function buildView(FormView $view, FormInterface $form, array $options)
{
foreach ($options as $key => $value) {
$view->set($key, $value);
}
$view->set('countries', $this->_getCountryList());
}
示例2: buildViewBottomUp
public function buildViewBottomUp(FormView $view, FormInterface $form)
{
foreach ($view->getChildren() as $child) {
/* @var \Symfony\Component\Form\FormView $child */
$child->set('full_name', $child->get('name'));
}
}
示例3: buildView
/**
* {@inheritdoc}
*/
public function buildView(FormView $view, FormInterface $form)
{
$view->set('value', $form->getAttribute('value'))->set('checked', (bool) $form->getClientData());
if ($view->hasParent()) {
$view->set('full_name', $view->getParent()->get('full_name'));
}
}
示例4: buildView
/**
* {@inheritdoc}
*/
public function buildView(FormView $view, FormInterface $form)
{
$configs = $form->getAttribute('configs');
$datas = $form->getClientData();
if (!empty($datas)) {
if ($form->getAttribute('multiple')) {
$datas = is_scalar($datas) ? explode(',', $datas) : $datas;
$value = array();
foreach ($datas as $data) {
if (!$data instanceof File) {
$data = new File($form->getAttribute('rootDir') . '/' . $data);
}
$value[] = $configs['folder'] . '/' . $data->getFilename();
}
$value = implode(',', $value);
} else {
if (!$datas instanceof File) {
$datas = new File($form->getAttribute('rootDir') . '/' . $datas);
}
$value = $configs['folder'] . '/' . $datas->getFilename();
}
$view->set('value', $value);
}
$view->set('type', 'hidden')->set('configs', $form->getAttribute('configs'));
}
示例5: finishView
public function finishView(FormView $view, FormInterface $form, array $options)
{
$view->setAttribute('data-date', Util::ICUTojQueryDate($form->getAttribute('date_pattern')));
$timePattern = $form->getAttribute('time_pattern');
$view->setAttribute('data-time', Util::ICUTojQueryDate($timePattern));
$view->setAttribute('data-ampm', false !== strpos($timePattern, 'h') ? '1' : '0');
}
示例6: getRoot
private function getRoot(FormView $form)
{
while ($form->getParent() != null) {
$form = $form->getParent();
}
return $form;
}
示例7: buildView
/**
* {@inheritdoc}
*/
public function buildView(FormView $view, FormInterface $form)
{
$view->set('widget', $form->getAttribute('widget'));
if ('single_text' === $form->getAttribute('widget')) {
$view->set('type', 'datetime');
}
}
示例8: buildView
public function buildView(FormView $view, FormInterface $form, array $options)
{
$view->set('parent_field', $form->getAttribute('parent_field'));
$view->set('entity_alias', $form->getAttribute('entity_alias'));
$view->set('no_result_msg', $form->getAttribute('no_result_msg'));
$view->set('empty_value', $form->getAttribute('empty_value'));
}
示例9: zform
public function zform(\Symfony\Component\Form\FormView $field)
{
$attr = $field->get('attr', array());
$attr['class'] = 'zTextForm';
$field->set('attr', $attr);
return $this->helper->render(array('field' => $field, 'id' => 1));
}
示例10: buildView
/**
* {@inheritdoc}
*/
public function buildView(FormView $view, FormInterface $form)
{
$value = $form->getClientData();
// set string representation
if (true === $value) {
$value = 'true';
} else {
if (false === $value) {
$value = 'false';
} else {
if (null === $value) {
$value = 'null';
} else {
if (is_array($value)) {
$value = implode(', ', $value);
} else {
if ($value instanceof \DateTime) {
$value = $value->format('Y-m-d H:i:s');
} else {
if (is_object($value)) {
if (method_exists($value, '__toString')) {
$value = $value->__toString();
} else {
$value = get_class($value);
}
}
}
}
}
}
}
$view->set('value', (string) $value);
}
示例11: buildView
/**
* @param \Symfony\Component\Form\FormView $view
* @param \Symfony\Component\Form\FormInterface $form
*/
public function buildView(FormView $view, FormInterface $form)
{
$format = $form->getAttribute('format');
$imageSrc = $view->get('image_src');
if ($imageSrc !== null && $format !== null) {
$view->set('image_src', $this->imManager->getUrl($format, $imageSrc));
}
}
示例12: array
function it_changes_label_attribute_for(FormInterface $form, FormView $view, FormView $fileView)
{
$form->getName()->willReturn('file');
$view->offsetGet('file')->willReturn($fileView);
$view->vars = array('label_attr' => array());
$fileView->vars = array('id' => 'form_file_file');
$this->finishView($view, $form, array());
expect($view->vars['label_attr']['for'])->toBe('form_file_file');
}
示例13: buildViewBottomUp
/**
* Removes CSRF fields from all the form views except the root one.
*
* @param FormView $view The form view
* @param FormInterface $form The form
*/
public function buildViewBottomUp(FormView $view, FormInterface $form)
{
if ($view->hasParent() && $form->hasAttribute('csrf_field_name')) {
$name = $form->getAttribute('csrf_field_name');
if (isset($view[$name])) {
unset($view[$name]);
}
}
}
示例14: finishView
public function finishView(FormView $view, FormInterface $form, array $options)
{
/** @var FormView[] $fields */
if ($view->offsetExists('submit_group')) {
$fields = array($view->offsetGet('submit_group'));
$view->offsetUnset('submit_group');
$view->children = $view->children + $fields;
}
parent::finishView($view, $form, $options);
}
示例15: finishView
public function finishView(FormView $view, FormInterface $form, array $options)
{
$configs = array_merge($options['configs'], array('id' => $view->vars['id'], 'name_id' => $view->getChild('name')->vars['id'], 'original_name_id' => $view->getChild('originalName')->vars['id'], 'size_id' => $view->getChild('size')->vars['id'], 'title_id' => $view->getChild('title')->vars['id'], 'caption_id' => $view->getChild('caption')->vars['id'], 'description_id' => $view->getChild('description')->vars['id'], 'hash_id' => $view->getChild('hash')->vars['id'], 'enabled_id' => $view->getChild('enabled')->vars['id'], 'scheduled_for_deletion_id' => $view->getChild('scheduledForDeletion')->vars['id'], 'enabled_value' => false));
$file = $form->getData();
if ($file instanceof FileInterface && null !== $file->getId()) {
$configs['enabled_value'] = $file->isEnabled();
}
$this->session->set($view->vars['id'], $configs);
$view->vars['configs'] = $configs;
}