本文整理汇总了PHP中Symfony\Component\Form\FormView::setVar方法的典型用法代码示例。如果您正苦于以下问题:PHP FormView::setVar方法的具体用法?PHP FormView::setVar怎么用?PHP FormView::setVar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Form\FormView
的用法示例。
在下文中一共展示了FormView::setVar方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildView
/**
* {@inheritdoc}
*/
public function buildView(FormView $view, FormInterface $form, array $options)
{
$configs = $options['configs'];
$data = $form->getClientData();
if (!empty($data)) {
if (!$data instanceof Image) {
$data = new Image($form->getAttribute('rootDir') . '/' . $data);
}
if ($data->hasThumbnail($this->selected)) {
$thumbnail = $data->getThumbnail($this->selected);
$view->setVar('thumbnail', array('file' => $configs['folder'] . '/' . $thumbnail->getFilename(), 'width' => $thumbnail->getWidth(), 'height' => $thumbnail->getHeight()));
}
$value = $configs['folder'] . '/' . $data->getFilename();
$view->vars = array_replace($view->vars, array('value' => $value, 'file' => $value, 'width' => $data->getWidth(), 'height' => $data->getHeight()));
}
$view->vars['filters'] = $this->filters;
}
示例2: buildView
/**
* {@inheritdoc}
*/
public function buildView(FormView $view, FormInterface $form, array $options)
{
$datas = json_decode($form->getClientData(), true);
$value = '';
if (false === empty($datas)) {
if (true === $form->getAttribute('multiple')) {
foreach ($datas as $data) {
$value .= $data['label'] . ', ';
}
} else {
$value = $datas['label'];
}
}
$view->setVar('tokeninput_value', $value)->setVar('route_name', $form->getAttribute('route_name'));
foreach ($this->_availableTokeninputOptions as $option) {
if ($form->hasAttribute($option)) {
$view->set($option, $form->getAttribute($option));
}
}
}
示例3: buildView
/**
* {@inheritdoc}
*/
public function buildView(FormView $view, FormInterface $form, array $options)
{
$view->setVar('widget', $form->getAttribute('widget'))->setVar('configs', $form->getAttribute('configs'));
}