本文整理汇总了PHP中Symfony\Component\Form\FormBuilderInterface::getForm方法的典型用法代码示例。如果您正苦于以下问题:PHP FormBuilderInterface::getForm方法的具体用法?PHP FormBuilderInterface::getForm怎么用?PHP FormBuilderInterface::getForm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Form\FormBuilderInterface
的用法示例。
在下文中一共展示了FormBuilderInterface::getForm方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildForm
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$data = $builder->getData();
$builder->add('loginType', 'choice', ['choices' => $this->getAvailableTypes((string) $builder->getForm()->getPropertyPath()), 'expanded' => true, 'attr' => ['class' => 'btn-group', 'data-toggle' => 'buttons', 'data-login-type-toggle' => null], 'data' => $data && $data->getLoginType() ? $data->getLoginType() : Login::TYPE_NONE])->add('databaseName', null, ['attr' => ['data-login-type' => Login::TYPE_DB]])->add('username', null, ['attr' => ['data-login-type' => implode(' ', [Login::TYPE_SITE, Login::TYPE_SSH, Login::TYPE_DB])]])->add('password', null, ['attr' => ['data-login-type' => implode(' ', [Login::TYPE_SITE, Login::TYPE_SSH, Login::TYPE_DB])]])->add('sshKey', null, ['attr' => ['help-block' => 'The text of a PEM file used for login', 'data-login-type' => Login::TYPE_SSH]])->add('hostname', null, ['attr' => ['help-block' => 'DNS name for this login', 'data-login-type' => implode(' ', [Login::TYPE_SSH, Login::TYPE_DB])]])->add('port', null, ['attr' => ['data-login-type' => implode(' ', [Login::TYPE_SSH, Login::TYPE_DB])]])->add('url', null, ['attr' => ['data-login-type' => Login::TYPE_SITE]]);
if ($this->includeProxy) {
$builder->add('proxyHost', new LoginType(false), ['attr' => ['data-login-type' => Login::TYPE_DB]]);
}
}
示例2: __construct
/**
* @param Request $request
* @param string $type
* @param array $data
* @param array $options
* @param ContainerInterface $container
* @deprecated Thelia forms should not be instantiated directly. Please use BaseController::createForm() instead
* @see BaseController::createForm()
*/
public function __construct(Request $request, $type = "form", $data = array(), $options = array(), ContainerInterface $container = null)
{
// Generate the form name from the complete class name
$this->formUniqueIdentifier = strtolower(str_replace('\\', '_', get_class($this)));
$this->request = $request;
$this->type = $type;
if (null !== $container) {
$this->container = $container;
$this->dispatcher = $container->get("event_dispatcher");
$this->initFormWithContainer($type, $data, $options);
} else {
$this->initFormWithRequest($type, $data, $options);
}
if (!isset($options["csrf_protection"]) || $options["csrf_protection"] !== false) {
$this->formFactoryBuilder->addExtension(new CsrfExtension(new CsrfTokenManager(null, new SessionTokenStorage($this->getRequest()->getSession()))));
}
$this->formBuilder = $this->formFactoryBuilder->addExtension(new ValidatorExtension($this->validatorBuilder->getValidator()))->getFormFactory()->createNamedBuilder($this->getName(), $type, $data, $this->cleanOptions($options));
/**
* Build the form
*/
$name = $this->getName();
$event = null;
$dispatchEvents = $this->hasContainer() && $name !== null && $name !== '';
// We need to wrap the dispatch with a condition for backward compatibility
if ($dispatchEvents) {
$event = new TheliaFormEvent($this);
/**
* If the form has the container, disptach the events
*/
$this->dispatcher->dispatch(TheliaEvents::FORM_BEFORE_BUILD . "." . $name, $event);
}
$this->buildForm();
if ($dispatchEvents) {
/**
* If the form has the container, disptach the events
*/
$this->dispatcher->dispatch(TheliaEvents::FORM_AFTER_BUILD . "." . $name, $event);
}
// If not already set, define the success_url field
// This field is not included in the standard form hidden fields
// This field is not included in the hidden fields generated by form_hidden_fields Smarty function
if (!$this->formBuilder->has('success_url')) {
$this->formBuilder->add("success_url", "hidden");
}
// If not already set, define the error_url field
// This field is not included in the standard form hidden fields
// This field is not included in the hidden fields generated by form_hidden_fields Smarty function
if (!$this->formBuilder->has('error_url')) {
$this->formBuilder->add("error_url", "hidden");
}
// The "error_message" field defines the error message displayed if
// the form could not be validated. If it is empty, a standard error message is displayed instead.
// This field is not included in the hidden fields generated by form_hidden_fields Smarty function
if (!$this->formBuilder->has('error_message')) {
$this->formBuilder->add("error_message", "hidden");
}
$this->form = $this->formBuilder->getForm();
}
示例3: buildForm
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('configItems', 'collection', array('type' => new ConfigType(), 'allow_add' => true, 'allow_delete' => true, 'by_reference' => false, 'label' => 'Clés de Configuration', 'options' => array('error_bubbling' => true, 'data_class' => 'AssoMaker\\PHPMBundle\\Entity\\Config')));
$builder->add('equipeItems', 'collection', array('type' => new EquipeType(), 'allow_add' => true, 'allow_delete' => true, 'by_reference' => false, 'label' => 'Équipes', 'options' => array('error_bubbling' => true, 'data_class' => 'AssoMaker\\BaseBundle\\Entity\\Equipe')));
$builder->add('registrationTokenItems', 'collection', array('type' => new RegistrationTokenType(), 'allow_add' => true, 'allow_delete' => true, 'by_reference' => false, 'label' => "Jetons d'inscription", 'options' => array('error_bubbling' => true, 'data_class' => 'AssoMaker\\BaseBundle\\Entity\\RegistrationToken')));
$builder->add('confianceItems', 'collection', array('type' => new ConfianceType(), 'allow_add' => true, 'allow_delete' => true, 'by_reference' => false, 'label' => 'Niveaux de Confiance', 'options' => array('error_bubbling' => true, 'data_class' => 'AssoMaker\\BaseBundle\\Entity\\Confiance')));
$builder->add('materielItems', 'collection', array('type' => new MaterielType(), 'allow_add' => true, 'allow_delete' => true, 'by_reference' => false, 'label' => 'Matériel', 'options' => array('error_bubbling' => true, 'data_class' => 'AssoMaker\\PHPMBundle\\Entity\\Materiel')));
$form = $builder->getForm();
}
示例4: createForm
public function createForm(FormBuilderInterface $formBuilder)
{
$formBuilder->setMethod('GET');
$formBuilder->add('status', ChoiceType::class, ['label' => 'Status', 'choices' => $this->translateStatus(AreaRequest::statusList()), 'required' => false]);
$formBuilder->add('territory', ChoiceType::class, ['label' => 'Territory', 'choices' => $this->territoryRepository->getFormChoices(), 'required' => false]);
$formBuilder->add('submit', SubmitType::class, ['label' => 'Filter']);
$formBuilder->get('territory')->addModelTransformer(new EntityTransformer($this->territoryRepository));
return $formBuilder->getForm();
}
示例5: buildForm
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('name', 'text', array('trim' => true, 'label' => 'Nom de la chaine'));
$builder->add('imageFile', FileType::class, array('trim' => true, 'label' => 'Illustration', 'attr' => array('class' => 'file', 'data-show-upload' => 'false'), 'required' => false));
$channel = $builder->getData();
if ($channel != null) {
$form = $builder->getForm();
$form->get('imageFile')->setData($channel->getImageFile());
}
}
示例6: buildForm
public function buildForm(FormBuilderInterface $builder, array $options)
{
if (!$options['edit']) {
$builder->add('username', 'text', ['label' => 'Nazwa użytkownika']);
}
if ($options['edit']) {
$builder->add('oldPassword', 'password', ['label' => 'Obecne hasło', 'mapped' => false, 'required' => false, 'constraints' => [new UserPassword(['message' => 'Niepoprawne hasło.', 'groups' => ['change_password']])]]);
}
$builder->add('email')->add('newPassword', 'repeated', ['type' => 'password', 'invalid_message' => 'Hasła muszą być jednakowe', 'first_options' => ['label' => 'Hasło'], 'second_options' => ['label' => 'Powtórz hasło'], 'required' => !$options['edit'], 'mapped' => false])->add('firstName', 'text', ['label' => 'Imię'])->add('lastName', 'text', ['label' => 'Nazwisko'])->add('address', 'text', ['label' => 'Adres'])->add('address2', 'text', ['label' => 'Adres c. d.'])->add('zip', 'text', ['label' => 'Kod pocztowy'])->add('city', 'text', ['label' => 'Miasto'])->add('state', 'text', ['label' => 'Województwo'])->add('country', 'country', ['label' => 'Kraj', 'data' => $options['edit'] ? $builder->getForm()->getData()->getCountry() : 'PL']);
}
示例7: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
/** @var LineItem $formData */
$formData = $builder->getForm()->getData();
$product = $formData->getProduct();
$builder->add('quantity', 'text', ['required' => true, 'label' => 'orob2b.shoppinglist.lineitem.quantity.label'])->add('unit', ProductUnitSelectionType::NAME, ['required' => true, 'label' => 'orob2b.shoppinglist.lineitem.unit.label', 'query_builder' => function (ProductUnitRepository $repository) use($product) {
return $repository->getProductUnitsQueryBuilder($product);
}]);
$builder->addEventSubscriber($this->lineItemSubscriber);
}
示例8: buildForm
public function buildForm(FormBuilderInterface $builder, array $options)
{
$choixDecalage = array();
for ($i = 1; $i <= 12; $i++) {
$s = 3600 * $i;
$choixDecalage[$s] = "{$i} h";
}
for ($i = 1; $i <= 7; $i++) {
$s = 24 * 3600 * $i;
$choixDecalage[$s] = "{$i} j";
}
$builder->add('disponibiliteInscriptionItems', 'entity', array('class' => 'AssoMakerPHPMBundle:DisponibiliteInscription', 'expanded' => true, 'multiple' => true, 'by_reference' => false, 'label' => 'Di'))->add('decalage', 'choice', array('label' => 'Avec un décalage de', 'choices' => $choixDecalage, 'empty_value' => 'Dupliquer et décaler', 'required' => false))->add('statut', 'choice', array('label' => 'Statut', 'empty_value' => 'Changer le statut', 'required' => false, 'choices' => array('0' => 'Verrouillé', '1' => 'Cochable Uniquement', '2' => 'Cochable/Décochable')))->add('mission', 'entity', array('class' => 'AssoMakerPHPMBundle:Mission', 'label' => 'Groupe', 'empty_value' => 'Changer la mission', 'required' => false))->add('pointsCharisme', null, array('label' => 'Points de Charisme', 'required' => false, 'attr' => array('placeHolder' => 'Changer les points de charisme')))->add('confiance', 'entity', array('class' => 'AssoMakerBaseBundle:Confiance', 'label' => 'Affecter les orgas', 'empty_value' => 'Affecter les orgas', 'required' => false))->add('confiance2', 'entity', array('class' => 'AssoMakerBaseBundle:Confiance', 'label' => 'Désaffecter les orgas', 'empty_value' => 'Désaffecter les orgas', 'required' => false));
$form = $builder->getForm();
}
示例9: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
if ($builder->getForm()->getName() == CustomEntityType::NAME) {
return;
}
$className = !empty($options['data_class']) ? $options['data_class'] : null;
if (!$className) {
return;
}
if (!$this->extendManager->getConfigProvider()->hasConfig($className)) {
return;
}
if (!$this->hasActiveFields($className)) {
return;
}
$builder->add('additional', CustomEntityType::NAME, array('inherit_data' => true, 'class_name' => $className));
}
示例10: renderForm
/**
* Render a form and return the HTML.
*/
private function renderForm(FormBuilderInterface $formBuilder)
{
$formView = $formBuilder->getForm()->createView();
$templating = $this->getContainer()->get('templating');
return $templating->render('::form.html.twig', array('form' => $formView));
}
示例11: __construct
/**
* @param HandlerInterface[]|array $requestHandlers
* @param \Symfony\Component\Form\FormBuilderInterface $formBuilder
*/
public function __construct(array $requestHandlers, FormBuilderInterface $formBuilder)
{
parent::__construct($requestHandlers);
$this->form = $formBuilder->getForm();
}
示例12: buildForm
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$instrument = $builder->getForm()->getData();
$builder->add('name')->add('newPrice')->add('price')->add('description')->add('features')->add('vendor', 'entity', array('class' => 'AppBundle\\Entity\\Vendor'))->add('category', 'entity', array('class' => 'AppBundle\\Entity\\Category'))->add('gallery', 'comur_gallery', array('uploadConfig' => array('uploadRoute' => 'comur_api_upload', 'uploadUrl' => $instrument->getUploadRootDir(), 'webDir' => $instrument->getUploadDir(), 'fileExt' => '*.jpg;*.gif;*.png;*.jpeg', 'libraryDir' => null, 'libraryRoute' => 'comur_api_image_library', 'showLibrary' => true), 'cropConfig' => array('minWidth' => 500, 'minHeight' => 500, 'aspectRatio' => true, 'cropRoute' => 'comur_api_crop', 'forceResize' => false, 'thumbs' => array(array('maxWidth' => 400, 'maxHeight' => 400, 'useAsFieldImage' => true)))));
}
示例13: buildForm
/**
* Builds the form.
*
* @param \Sonata\AdminBundle\Util\AdminObjectAclData $data
* @param \Symfony\Component\Form\FormBuilderInterface $formBuilder
* @param \Traversable $aclValues
*
* @return \Symfony\Component\Form\Form
*/
protected function buildForm(AdminObjectAclData $data, FormBuilderInterface $formBuilder, \Traversable $aclValues)
{
// Retrieve object identity
$objectIdentity = ObjectIdentity::fromDomainObject($data->getObject());
$acl = $data->getSecurityHandler()->getObjectAcl($objectIdentity);
if (!$acl) {
$acl = $data->getSecurityHandler()->createAcl($objectIdentity);
}
$data->setAcl($acl);
$masks = $data->getMasks();
$securityInformation = $data->getSecurityInformation();
foreach ($aclValues as $key => $aclValue) {
$securityIdentity = $this->getSecurityIdentity($aclValue);
$permissions = array();
foreach ($data->getUserPermissions() as $permission) {
try {
$checked = $acl->isGranted(array($masks[$permission]), array($securityIdentity));
} catch (NoAceFoundException $e) {
$checked = false;
}
$attr = array();
if (self::ACL_ROLES_FORM_NAME === $formBuilder->getName() && isset($securityInformation[$aclValue]) && array_search($permission, $securityInformation[$aclValue]) !== false) {
$attr['disabled'] = 'disabled';
}
$permissions[$permission] = array('required' => false, 'data' => $checked, 'disabled' => array_key_exists('disabled', $attr), 'attr' => $attr);
}
$formBuilder->add($key, new AclMatrixType(), array('permissions' => $permissions, 'acl_value' => $aclValue));
}
return $formBuilder->getForm();
}
示例14: buildForm
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$media = $builder->getForm()->getData();
$builder->add('image', 'comur_image', array('uploadConfig' => array('uploadRoute' => 'comur_api_upload', 'uploadUrl' => $media->getUploadRootDir(), 'webDir' => $media->getUploadDir(), 'fileExt' => '*.jpg;*.gif;*.png;*.jpeg', 'libraryDir' => null, 'libraryRoute' => 'comur_api_image_library', 'showLibrary' => false), 'cropConfig' => array('minWidth' => 400, 'minHeight' => 400, 'aspectRatio' => true, 'cropRoute' => 'comur_api_crop', 'forceResize' => false, 'thumbs' => array(array('maxWidth' => 400, 'maxHeight' => 400, 'useAsFieldImage' => false)))));
}
示例15: buildPager
/**
* {@inheritdoc}
*/
public function buildPager()
{
if ($this->bound) {
return;
}
foreach ($this->getFilters() as $name => $filter) {
list($type, $options) = $filter->getRenderSettings();
$this->formBuilder->add($filter->getFormName(), $type, $options);
}
$this->formBuilder->add('_sort_by', 'hidden');
$this->formBuilder->get('_sort_by')->addViewTransformer(new CallbackTransformer(function ($value) {
return $value;
}, function ($value) {
return $value instanceof FieldDescriptionInterface ? $value->getName() : $value;
}));
$this->formBuilder->add('_sort_order', 'hidden');
$this->formBuilder->add('_page', 'hidden');
$this->formBuilder->add('_per_page', 'hidden');
$this->form = $this->formBuilder->getForm();
$this->form->submit($this->values);
$data = $this->form->getData();
foreach ($this->getFilters() as $name => $filter) {
$this->values[$name] = isset($this->values[$name]) ? $this->values[$name] : null;
$filter->apply($this->query, $data[$filter->getFormName()]);
}
if (isset($this->values['_sort_by'])) {
if (!$this->values['_sort_by'] instanceof FieldDescriptionInterface) {
throw new UnexpectedTypeException($this->values['_sort_by'], 'FieldDescriptionInterface');
}
if ($this->values['_sort_by']->isSortable()) {
$this->query->setSortBy($this->values['_sort_by']->getSortParentAssociationMapping(), $this->values['_sort_by']->getSortFieldMapping());
$this->query->setSortOrder(isset($this->values['_sort_order']) ? $this->values['_sort_order'] : null);
}
}
$maxPerPage = 25;
if (isset($this->values['_per_page'])) {
// check for `is_array` can be safely removed if php 5.3 support will be dropped
if (is_array($this->values['_per_page'])) {
if (isset($this->values['_per_page']['value'])) {
$maxPerPage = $this->values['_per_page']['value'];
}
} else {
$maxPerPage = $this->values['_per_page'];
}
}
$this->pager->setMaxPerPage($maxPerPage);
$page = 1;
if (isset($this->values['_page'])) {
// check for `is_array` can be safely removed if php 5.3 support will be dropped
if (is_array($this->values['_page'])) {
if (isset($this->values['_page']['value'])) {
$page = $this->values['_page']['value'];
}
} else {
$page = $this->values['_page'];
}
}
$this->pager->setPage($page);
$this->pager->setQuery($this->query);
$this->pager->init();
$this->bound = true;
}