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

Shouldn't ID be hidden in edit and new forms #94

Open
matejvelikonja opened this issue Mar 27, 2015 · 6 comments
Open

Shouldn't ID be hidden in edit and new forms #94

matejvelikonja opened this issue Mar 27, 2015 · 6 comments

Comments

@matejvelikonja
Copy link
Contributor

When you have auto generated Id it makes sense that you cannot edit or create it. It's should be hidden by default.

@sescandell
Copy link
Member

I think they should simply not be part of the form.

But this imply we add some logic on "default" behavior analyzing what is the primary key on so on.

That could be great!

@ioleo ioleo added this to the next release milestone Apr 13, 2015
@ioleo
Copy link
Member

ioleo commented Apr 13, 2015

This is not top priority, as you can easily control which fields are displayed by customizing the display or tabs option in New/Edit builder. Marking for next release.

@matejvelikonja
Copy link
Contributor Author

But you can't say which properties you don't want, right? Like blacklisting.

@ioleo
Copy link
Member

ioleo commented Apr 13, 2015

@matejvelikonja currently there is one way to do that:

if you wish to "blacklist" fields, you could do that by extending the FormType.

<?php

namespace Acme\DemoBundle\Form\Type\Post;

use Admingenerated\AcmeDemoBundle\Form\BasePostType\EditType as BaseEditType;
use Symfony\Component\Form\FormBuilderInterface;

/**
 * EditType
 */
class EditType extends BaseEditType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        parent::buildForm($builder, $options);

        // assuming you let "by default" all fields
        // you can blacklist a specific field by removeing it in the form type
        $builder->remove('id');
    }
}

@ioleo
Copy link
Member

ioleo commented Apr 13, 2015

Also, I don't actually see value in implementing a "blacklist" feature. As metioned above - we could detect the "primary key" and not include it by default, but "blacklisting" more fields is IMHO doing it the wrong way.

@sescandell
Copy link
Member

Hi,

But you can't say which properties you don't want, right? Like blacklisting.

No, but by default, if you define which ones you want, others ones are not included

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

No branches or pull requests

3 participants