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

New Symfony 2.8 change: form field types are class names #623

Closed
weaverryan opened this issue Nov 17, 2015 · 9 comments
Closed

New Symfony 2.8 change: form field types are class names #623

weaverryan opened this issue Nov 17, 2015 · 9 comments
Labels

Comments

@weaverryan
Copy link

Hi there!

I <3 this plugin, and I usually if something isn't up to date, it suddenly is a few days later!

For Symfony 2.8, the form types have changed from being a string (e.g. text) to being a full class name:

// before
$builder->add('username', 'text');
// after
$builder->add('username', TextType::class);

In PhpStorm itself, the only unfortunate thing is that typing TextType does not bring up the TextType class as an auto-complete suggestion, because it has no static methods/constants/properties. So, you need to type TextType::class, and then go back and "Import class" to add the use statement. Ideally - if this is possible - it would auto-complete known classes that implement FormTypeInterface in the project.

If I can help with this, I'd be happy to assist.

Thanks!

@Haehnchen
Copy link
Owner

same on Doctrine getRepository; annoying behavior. want to start with a quickfix overlay first to replace string with class constant. will search for a suitable completion solution.

@weaverryan
Copy link
Author

@Haehnchen Oh yea, good point about Doctrine getRepository! Thanks!

@MisatoTremor
Copy link

@Haehnchen This change also seems to break the form type options autocompletion.

Haehnchen added a commit that referenced this issue Dec 4, 2015
…pports constants and property string values; cleanup some unused form code
@Haehnchen
Copy link
Owner

completion done. also added intention and generator for migration

@weaverryan
Copy link
Author

Wow, you rock: I'll be very interested to show people the migration aspect. Thanks!

@Haehnchen
Copy link
Owner

migration and many other stuff is useless because of #651 :)

@hoshsadiq
Copy link

Sorry to open an older ticket, but the same is the case for other sitations:

  • from in QueryBuilder (probably other things too):

    $qb = new QueryBuilder($em);
    $qb->select('t')->from(MyEntity::class, 't');
  • Additionally the above, doesn't provide further autocomplete:

    $qb = new QueryBuilder($em);
    $qb->select('t')->from(MyEntity::class, 't')
    ->leftJoin('t.someField', 'sf'); // if you use MyEntity::class it doesn't provide autocomplete for someField, but if you use the currently support ways, it does. The same is the case in other statements such as where etc.
  • EntityType::class type in the option class:

    $builder->add(
        'someRelations',
        'entity',
        array(
            'class' => SomeRelation::class
        )
    );
  • EntityManager::getReference():

    $this->entityManager->getReference(MyEntity::class, $id);
  • OptionsResolver::setAllowedTypes:

    $resolver->setAllowedTypes('em', ObjectManager::class);
  • Final one I could find is in doctrine queries themselves:

    $em->createQuery('SELECT t FROM '.MyEntity::class.' t');

@dewos
Copy link

dewos commented Jun 9, 2016

I'm +1 for @hoshsadiq question. @Haehnchen any news about this one?
it would be useful

@hoshsadiq
Copy link

Aah damn, I was meant to raise a new issue with that as this one is closed. Totally forgot.

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

No branches or pull requests

5 participants