Adding new field to user...

Hello,



I’m trying to add a new field to users. I would like to specify a “pre-filter” that will apply to all queries done by the user. Any suggestion?



I added the field to the user class but I think this will create some problems in future when I will update mautic…



thank you for your answer.

Hello,

I’m trying to add a new field to users. I would like to specify a “pre-filter” that will apply to all queries done by the user. Any suggestion?

I added the field to the user class but I think this will create some problems in future when I will update mautic…

thank you for your answer.

these are the changes I have done to the userbundle. I tried to extend the bundle creating a custom bundle but nothing. probably I wrong something … Please let me know…

[code]File-> UserBundleEntityUser.php

row: 134
/**
* @var string
*/
private $prefilter;

row: 216 function: loadMetadata
$builder->createField(‘prefilter’, ‘text’)
->nullable()
->build();

row: 289
/**
* Set prefilter.
*
* @param string $prefilter
*
* @return User
*/
public function setPrefilter($prefilter)
{
$this->isChanged(‘prefilter’, $prefilter);
$this->prefilter = $prefilter;

    return $this;
}

/**
 * Get prefilter.
 *
 * @return string
 */
public function getPrefilter()
{
    return $this->prefilter;
}

File-> UserBundleFormTypeUserType.php

row: 250 function: buildForm

$defaultPrefilter = ‘’;
if (isset($options[‘data’]) && $options[‘data’]->getPrefilter() === null) {
$defaultPrefilter = ‘’;
} elseif (isset($options[‘data’])) {
$defaultPrefilter = $options[‘data’]->getPrefilter();
}

    $builder->add(
        'prefilter',
        'textarea',
        [
            'label'      => 'Prefilter',
            'label_attr' => ['class' => 'control-label'],
            'required'   => false,
            'attr'       => [
                'class' => 'form-control',
            ],
            'data' => $defaultPrefilter,
        ]
    );

File->bundles/UserBundle/Views/Profile

row: 69
echo $view[‘form’]->row($userForm[‘prefilter’]);
[/code]