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

How do I use this bundle in Symfony 3.1? #435

Open
ozzmaster opened this issue Aug 5, 2016 · 10 comments
Open

How do I use this bundle in Symfony 3.1? #435

ozzmaster opened this issue Aug 5, 2016 · 10 comments

Comments

@ozzmaster
Copy link

ozzmaster commented Aug 5, 2016

This is my old Form Builder code:

public function buildForm(FormBuilderInterface $builder, array $options) {
    ...
    $builder->add(
                'redeemed_at', 'genemu_jqueryselect2_choice',
                array('label' =>'Voucher Redeemed At: *', 'choices' => $dealerships, 'mapped' => false)
        );
    ...
}

If I use this, as per the examples and as I do in Symfony 2.x projects, Symfony 3.1 gives me this:
Could not load type "genemu_jqueryselect2_choice"

After I used the new style and scratched around in this bundle for the correct form class, I tried this:

public function buildForm(FormBuilderInterface $builder, array $options) {
    ...
    $builder->add(
                'redeemed_at', Select2Type::class,
                array('label' =>'Voucher Redeemed At: *', 'choices' => $dealerships, 'mapped' => false)
        );
    ...
}

Now I get this:
Warning: Missing argument 1 for Genemu\Bundle\FormBundle\Form\JQuery\Type\Select2Type::__construct()

Is that the correct class?

I would really prefer to use this bundle, as I have in the past, instead of abandoning it!

PLEASE HELP!

@ghost
Copy link

ghost commented Aug 23, 2016

Do you have already found a solution for that?

@ozzmaster
Copy link
Author

No. I implemented Select2 by specifying a normal 'choice' type and then adding the necessary Javascript files and calls to the form template. I would still appreciate a solution as I have other projects that I want to upgrade to Symfony 3.x from Symfony 2.x. They are all using this bundle.

@zigomario
Copy link

I have exactly same problem.
i have find
how to bypass it.
In the file directly .... we define $ widget in the constructor with the desired type.
Example, I need EntityType with select2 :

public function __construct($widget ='Entity', array $configs = array())
    {
        $this->widget = $widget;
        $this->configs = $configs;
    }

We agree, it's ugly and totally forbidden to do that.
But as I am a newbie with POO, I do not understand :

XxxTYPE :: class

what is ":: class"?

@benschumi
Copy link

Although it is marked compliant 3.X, it is not.

I fork and rewrite the bundle to be compatible waiting for a compatible version.

@Kanouille
Copy link

Kanouille commented Nov 23, 2016

Hi,
First, thanks @benschumi to working on a compatible version.
But in the meantime, I think I found a clean solution for waiting your PR.
But I need your feedback for this.

I needed only genemu_jqueryselect2 forms.
So, i created a formType extends Select2Type.
Example:

use Genemu\Bundle\FormBundle\Form\JQuery\Type\Select2Type;

/**
 * Select2EntityType
 */
class Select2EntityType extends Select2Type
{
    /**
     * The constructor
     */
    public function __construct()
    {
        parent::__construct('entity');
    }
}

I had no specific configurations into my config.yml for genum_form.select2. So, I assumed this simple object could overload the service generate by GenemuFormExtension, and it works. I can use this formType to replace the generic service 'genemu_jqueryselect2_entity'.

Can you confirm that works for your too ?

@Stoakes
Copy link

Stoakes commented Jan 5, 2017

Hi,

I know that issue is rather old, but it seems that @benschumi /form-bundle isn't refered in Packagist anymore. Is it normal ?

Thanks

@benschumi
Copy link

Hi,

I never put it on Packagist.

@rusanter
Copy link

@benschumi, sorry for writing to you here, but I can't find the right place.
Can you please add "replace" section to a composer.json and list genemu/form-bundle there.
For more information, see https://getcomposer.org/doc/04-schema.md#replace

@benschumi
Copy link

I can't put a fork on packagist,

Do not submit forks of existing packages. If you need to test changes to a package that you forked to patch, use VCS Repositories instead.

If you want to use my fork, use vcs insteasd

{ "repositories": [ { "type": "vcs", "url": "https://github.com/benschumi/form-bundle" } ] }

@rusanter
Copy link

@benschumi
Sure I use your version exactly this way.
I also want to add more dependencies which require genemu/form-bundle.
And I want them to happily work with your version.
That's why I'm asking you about replacing genemu/form-bundle in composer.json.

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

6 participants