Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

form html output on page not same as schema #46

Closed
BernardA opened this issue Dec 11, 2017 · 1 comment
Closed

form html output on page not same as schema #46

BernardA opened this issue Dec 11, 2017 · 1 comment

Comments

@BernardA
Copy link

BernardA commented Dec 11, 2017

The form html is not taking into account placeholders and also it is not following set order on EntityType field.

This is working correctly in 'plain' Symfony.

The specific form field:

`

class AdType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
    $builder
        ->add('model', EntityType::class, array(
            'class' => 'UsedBundle:Model',
            'query_builder' => function (EntityRepository $er) {
                $model = $er->createQueryBuilder('m')
                    ->join('UsedBundle:Brand','b')
                    ->andWhere('b.id = m.brand')
                    ->andWhere("m.active = true")
                    ->addOrderBy('b.brand')
                    ->addOrderBy('m.model');
                return $model;
            },
            'choice_label' => function ($model) {
                $this->brand = $model->getBrand()->getBrand();
                $this->model_name = $model->getModel();
                return $this->brand . ' ' . $this->model_name;
            },
            'label' => false,
            'attr' => array(
                'placeholder' => 'Modele *',
                'data-validation' => 'required',
                'data-validation-error-msg' => "SVP, sélectionnez votre modele",  
                )  
            ))`

The schema is getting the correct info ( from console.log(adEntry.state))

`

model: {…}
attr: {…}
 "data-validation": "required"
 "data-validation-error-msg": "SVP, sélectionnez votre modele"
  placeholder: "Modele *"
 __proto__: Object { … }
  default: "Modele *"
  enum: Array [ "211", "212", "287", … ]
 enum_titles: Array [ "Abarth 500", "Abarth 500C", "Alfa Romeo 146", … ]
 propertyOrder: 1
 title: "model"
 type: "string"`

But the output is leaving aside the order above ( from enum and enum_titles ) and ordering by <option value""> ascending.

Also the placeholder or default option is not being taken into account, even though the schema is correct. This for all fields.

html

`

<option value="1">Dacia Sandero</option>
<option value="3">Dacia Lodgy</option>
<option value="4">Dacia Dokker</option>
<option value="7">Ford Ka</option>
  ...........`

Thanks

@nacmartin
Copy link
Member

Ok, thanks for this report. I have opened an issue on its library (this is a sandbox with examples of usage of these libraries).

Regarding placeholders, there were complains saying that placeholders shouldn't be default choices, so it was removed in a recent version. There must be room for improvement here though. Limenius/Liform#17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants