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


PHP FormInterface::getClientData方法代码示例

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


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

示例1: buildView

 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form)
 {
     $name = $form->getName();
     $readOnly = $form->getAttribute('read_only');
     if ($view->hasParent()) {
         if ('' === $name) {
             throw new FormException('Form node with empty name can be used only as root form node.');
         }
         if ('' !== ($parentFullName = $view->getParent()->get('full_name'))) {
             $id = sprintf('%s_%s', $view->getParent()->get('id'), $name);
             $fullName = sprintf('%s[%s]', $parentFullName, $name);
         } else {
             $id = $name;
             $fullName = $name;
         }
         // Complex fields are read-only if themselves or their parent is.
         $readOnly = $readOnly || $view->getParent()->get('read_only');
     } else {
         $id = $name;
         $fullName = $name;
         // Strip leading underscores and digits. These are allowed in
         // form names, but not in HTML4 ID attributes.
         // http://www.w3.org/TR/html401/struct/global.html#adef-id
         $id = ltrim($id, '_0123456789');
     }
     $types = array();
     foreach ($form->getTypes() as $type) {
         $types[] = $type->getName();
     }
     $view->set('form', $view)->set('id', $id)->set('name', $name)->set('full_name', $fullName)->set('read_only', $readOnly)->set('errors', $form->getErrors())->set('value', $form->getClientData())->set('disabled', $form->isDisabled())->set('required', $form->isRequired())->set('max_length', $form->getAttribute('max_length'))->set('pattern', $form->getAttribute('pattern'))->set('size', null)->set('label', $form->getAttribute('label'))->set('multipart', false)->set('attr', $form->getAttribute('attr'))->set('types', $types)->set('translation_domain', $form->getAttribute('translation_domain'));
 }
开发者ID:421p,项目名称:symfony,代码行数:34,代码来源:FormType.php

示例2: 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'));
     }
 }
开发者ID:artz20,项目名称:Tv-shows-zone,代码行数:10,代码来源:RadioType.php

示例3: buildView

 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form)
 {
     $name = $form->getName();
     if ($view->hasParent()) {
         if ('' === $name) {
             throw new FormException('Form node with empty name can be used only as root form node.');
         }
         if ('' !== ($parentFullName = $view->getParent()->get('full_name'))) {
             $id = sprintf('%s_%s', $view->getParent()->get('id'), $name);
             $fullName = sprintf('%s[%s]', $parentFullName, $name);
         } else {
             $id = $name;
             $fullName = $name;
         }
     } else {
         // If this form node have empty name, set id to `form`
         // to avoid rendering `id=""` in html structure
         $id = $name ?: 'form';
         $fullName = $name;
     }
     $types = array();
     foreach ($form->getTypes() as $type) {
         $types[] = $type->getName();
     }
     $view->set('form', $view)->set('id', $id)->set('name', $name)->set('full_name', $fullName)->set('errors', $form->getErrors())->set('value', $form->getClientData())->set('read_only', $form->isReadOnly())->set('required', $form->isRequired())->set('max_length', $form->getAttribute('max_length'))->set('pattern', $form->getAttribute('pattern'))->set('size', null)->set('label', $form->getAttribute('label'))->set('multipart', false)->set('attr', $form->getAttribute('attr'))->set('types', $types)->set('translation_domain', $form->getAttribute('translation_domain'));
 }
开发者ID:rudott,项目名称:symfony,代码行数:29,代码来源:FieldType.php

示例4: buildView

 /**
  * {@inheritdoc}
  */
 public function buildView(FormViewInterface $view, FormInterface $form, array $options)
 {
     $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'));
 }
开发者ID:r4cker,项目名称:GenemuFormBundle,代码行数:28,代码来源:FileType.php

示例5: buildView

 public function buildView(FormView $view, FormInterface $form)
 {
     if ($view->hasParent()) {
         $parentId = $view->getParent()->get('id');
         $parentName = $view->getParent()->get('name');
         $id = sprintf('%s_%s', $parentId, $form->getName());
         $name = sprintf('%s[%s]', $parentName, $form->getName());
     } else {
         $id = $form->getName();
         $name = $form->getName();
     }
     $view->set('form', $view);
     $view->set('id', $id);
     $view->set('name', $name);
     $view->set('errors', $form->getErrors());
     $view->set('value', $form->getClientData());
     $view->set('read_only', $form->isReadOnly());
     $view->set('required', $form->isRequired());
     $view->set('max_length', $form->getAttribute('max_length'));
     $view->set('size', null);
     $view->set('label', $form->getAttribute('label'));
     $view->set('multipart', false);
     $view->set('attr', array());
     $types = array();
     foreach (array_reverse((array) $form->getTypes()) as $type) {
         $types[] = $type->getName();
     }
     $view->set('types', $types);
 }
开发者ID:norwayapp,项目名称:Invest,代码行数:29,代码来源:FieldType.php

示例6: 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);
 }
开发者ID:raziel057,项目名称:GenemuFormBundle,代码行数:36,代码来源:PlainType.php

示例7: buildView

 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form)
 {
     $request = $this->request;
     $configs = $form->getAttribute('configs');
     $data = $form->getClientData();
     $fileMeta = new Upload();
     $uploadDir = "/web/temp";
     $uploadDir .= '/' . date("Y") . '/' . date("m") . '/' . date("d");
     $relativeFilePath = $uploadDir;
     $absolutePath = str_replace('/', '//', $request->getRootDir());
     $absolutePath = str_replace('\\', '\\\\', $absolutePath);
     if (!empty($data)) {
         $absoluteFilePath = $request->getRootDir() . '/../' . $data->getPath() . '/' . $data->getUniqId();
         $relativeFilePath = $data->getPath() . '/' . $data->getUniqId();
         $relativePath = $data->getPath();
         $fileMeta = $this->em->getRepository('LowbiSystemBundle:Upload')->find($data->getId());
         if ($fileMeta == null) {
             $fileMeta = new Upload();
         }
         if ($fileMeta->getTodelete()) {
             try {
                 $this->em->remove($fileMeta);
                 $this->em->flush();
             } catch (\EXception $ex) {
             }
             $view->set('filePath', $relativeFilePath)->set('absolutePath', $absolutePath)->set('value', null)->set('fileMeta', $fileMeta);
             return;
         }
         if (!$data instanceof Image) {
             if ($data instanceof File) {
                 $data = new \Lowbi\SystemBundle\Gd\File\Image($absoluteFilePath);
             } else {
                 $data = new \Lowbi\SystemBundle\Gd\File\Image($absoluteFilePath);
             }
         }
         //if ($data->hasThumbnail($this->selected)) {
         $thumbnail = $data->getThumbnail($this->selected);
         $view->set('thumbnail', array('file' => $relativePath . '/' . $thumbnail->getFilename(), 'width' => $thumbnail->getWidth(), 'height' => $thumbnail->getHeight()));
         //}
         if ($configs['custom_storage_folder'] && false === ($value = $form->getClientData()) instanceof File) {
             // This if will be executed only when we load entity with existing file pointed to the folder different
             // from $configs['folder']
         } else {
             $value = $configs['folder'] . '/' . $data->getFilename();
         }
         $view->set('value', $value)->set('file', $value)->set('width', $data->getWidth())->set('height', $data->getHeight())->set('filePath', $relativeFilePath)->set('absolutePath', $absolutePath)->set('fileMeta', $fileMeta);
     } else {
         $view->set('filePath', $relativeFilePath)->set('absolutePath', $absolutePath)->set('fileMeta', $fileMeta);
     }
     $view->set('filters', $this->filters);
 }
开发者ID:r4cker,项目名称:lowbi,代码行数:54,代码来源:ImageType.php

示例8: buildView

 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form)
 {
     $datas = json_decode($form->getClientData(), true);
     $value = '';
     if (!empty($datas)) {
         if ($form->getAttribute('multiple')) {
             foreach ($datas as $data) {
                 $value .= $data['label'] . ', ';
             }
         } else {
             $value = $datas['label'];
         }
     }
     $view->set('autocompleter_value', $value)->set('route_name', $form->getAttribute('route_name'))->set('freeValues', $form->getAttribute('freeValues'));
 }
开发者ID:raziel057,项目名称:GenemuFormBundle,代码行数:18,代码来源:AutocompleterType.php

示例9: buildView

 /**
  * {@inheritdoc}
  */
 public function buildView(FormViewInterface $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->setVar('value', $value)->setVar('file', $value)->setVar('width', $data->getWidth())->setVar('height', $data->getHeight());
     }
     $view->setVar('filters', $this->filters);
 }
开发者ID:hykz,项目名称:Depot,代码行数:20,代码来源:ImageType.php

示例10: buildView

 /**
  * {@inheritdoc}
  */
 public function buildView(FormViewInterface $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->set('tokeninput_value', $value)->set('route_name', $form->getAttribute('route_name'));
     foreach ($this->_availableTokeninputOptions as $option) {
         if ($form->hasAttribute($option)) {
             $view->set($option, $form->getAttribute($option));
         }
     }
 }
开发者ID:r4cker,项目名称:GenemuFormBundle,代码行数:23,代码来源:TokeninputType.php

示例11: buildView

 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     $datas = json_decode($form->getClientData(), true);
     $value = '';
     if (!empty($datas)) {
         if ($options['multiple']) {
             foreach ($datas as $data) {
                 $value .= $data['label'] . ', ';
             }
         } else {
             $value = $datas['label'];
         }
     }
     $view->vars['tokeninput_value'] = $value;
     $view->vars['route_name'] = $form->getAttribute('route_name');
     foreach ($this->_availableTokeninputOptions as $option) {
         if (null !== $options[$option]) {
             $view->vars[$option] = $options[$option];
         }
     }
     array_splice($view->vars['block_prefixes'], array_search($this->getName(), $view->vars['block_prefixes']), 0, 'genemu_jquerytokeninput');
 }
开发者ID:r1pp3rj4ck,项目名称:GenemuFormBundle,代码行数:25,代码来源:TokeninputType.php

示例12: buildView

 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form)
 {
     $view->set('value', $form->getAttribute('value'))->set('checked', null !== $form->getClientData());
 }
开发者ID:rouffj,项目名称:symfony,代码行数:7,代码来源:CheckboxType.php

示例13: buildView

 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form)
 {
     $items = $form->getClientData();
     $deleteForm = array();
     $showForm = array();
     $formVars = $view->getVars();
     $fieldTypeName = $formVars['name'];
     if ($form->getAttribute('searchForm') == null) {
         $metaClass = $this->em->getClassMetadata($form->getAttribute('entityName'))->rootEntityName;
         $formType = str_replace('Entity', 'Form', $metaClass) . 'SearchType';
     } else {
         $formType = $form->getAttribute('searchForm');
     }
     $entityForm = $this->formFactory->create(new $formType());
     $columns = array();
     $columnsType = array();
     $columnsLabels = null;
     $itr = 0;
     if ($form->getAttribute('columns') == null) {
         foreach ($entityForm as $field) {
             if ($field->getName() != '_token') {
                 if ($itr >= 4) {
                     break;
                 }
                 $type = $this->lowbiSystem->guessFormFieldType($field);
                 $columns[] = $field->getName();
                 $columnsType[] = $type;
                 $columnsLabels[$field->getName()] = $field->getAttribute('label');
                 $itr++;
             }
         }
     } else {
         foreach ($entityForm as $item) {
             if (in_array($item->getName(), $form->getAttribute('columns'))) {
                 $label = $item->getAttribute('label');
                 if (!$label) {
                     $label = $item->getName();
                 }
                 $columnsLabels[$item->getName()] = $item->getAttribute('label');
             }
         }
         $columns = $form->getAttribute('columns');
         $columnsType = $form->getAttribute('columnsType');
     }
     if ($items != '' || $items != null) {
         $deleteForm[$items->getId()] = $this->createDeleteForm($items->getId(), $fieldTypeName)->createView();
         $showForm[$items->getId()] = $this->createShowForm($items->getId())->createView();
     }
     if ($form->getParent()->getClientData() != null) {
         if ($form->getParent()->getClientData()->getId() != null) {
             if (is_array($form->getClientData()) || is_object($form->getParent()->getClientData())) {
                 $sourceEntityId = $form->getParent()->getClientData()->getId();
                 $sourceEntityName = $this->getBundleName(get_class($form->getParent()->getClientData()));
             } else {
                 $sourceEntityId = $form->getClientData()->getOwner()->getId();
                 $sourceEntityName = $this->getBundleName(get_class($form->getClientData()->getOwner()));
             }
         } else {
             $sourceEntityId = null;
             $sourceEntityName = $this->getBundleName(get_class($form->getParent()->getClientData()));
         }
     } else {
         $sourceEntityId = null;
         $sourceEntityName = null;
     }
     //Create search form attributes
     $searchFormName = $formType;
     $searchForm = $this->formFactory->create(new $searchFormName());
     foreach ($searchForm as $field) {
         $type = $this->lowbiSystem->guessFormFieldType($field);
         if ($type == 'Date') {
             $oldField = $field;
             $searchForm->offsetUnset($field->getName());
             $label = $oldField->getAttribute('label');
             if (!$label) {
                 $label = $oldField->getName();
             }
             $exForm = $this->formFactory->createNamedBuilder('form', $oldField->getName(), null, array('label' => $label))->add($oldField->getName() . '_start', 'lowbi_date', array('label' => ' '))->add($oldField->getName() . '_end', 'lowbi_date', array('label' => ' '))->getForm();
             $searchForm->add($exForm);
         }
     }
     $extraForm = $this->createSearchForm($form, $fieldTypeName, $columns, $columnsType);
     $searchForm->add($extraForm);
     //disable actions when entire form is read only
     if ($form->getParent()->isReadOnly() || $sourceEntityId == null) {
         $actions = array('select' => false, 'remove' => false);
     } else {
         $actions = $form->getAttribute('actions');
     }
     $view->set('configs', $form->getAttribute('configs'))->set('columns', $columns)->set('columnsType', $columnsType)->set('columnsLabel', $columnsLabels)->set('actions', $actions)->set('sourceEntityName', $sourceEntityName)->set('sourceEntityId', $sourceEntityId)->set('entityName', $form->getAttribute('entityName'))->set('searchForm', $searchForm->createView())->set('deleteForm', $deleteForm)->set('showForm', $showForm)->set('items', $items);
 }
开发者ID:r4cker,项目名称:lowbi,代码行数:94,代码来源:SearchSelectType.php


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