-
Notifications
You must be signed in to change notification settings - Fork 77
Open
Description
| Q | A |
|---|---|
| Bug? | no |
| New Feature? | yes |
| Bundle Version | 2.5.4 |
| Sulu Version | 2.5.20 |
| Browser Version | - |
Actual Behavior
Hidden field types are defined statically (see
SuluFormBundle/Entity/Dynamic.php
Line 36 in 12d2df1
| public static $HIDDEN_TYPES = [ |
When using own field types columns for these types are shown, even it has the mapped option set to false.
Expected Behavior
Own field types should have the possibility to be defined as a "hidden" field type so that for it no column in the data tab is shown.
Steps to Reproduce
Example for a FriendlyCaptcha field type
Type config:
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="sulu_form.dynamic.type_friendlycaptcha" class="App\Form\FormBundle\FriendlyCaptchaFieldType">
<tag name="sulu_form.dynamic.type" alias="friendlycaptcha"/>
</service>
</services>
</container>
Field type class:
namespace App\Form\FormBundle;
use CORS\Bundle\FriendlyCaptchaBundle\Form\Type\FriendlyCaptchaType;
use CORS\Bundle\FriendlyCaptchaBundle\Validator\FriendlyCaptchaValid;
use Sulu\Bundle\FormBundle\Dynamic\FormFieldTypeConfiguration;
use Sulu\Bundle\FormBundle\Dynamic\FormFieldTypeInterface;
use Sulu\Bundle\FormBundle\Dynamic\Types\SimpleTypeTrait;
use Sulu\Bundle\FormBundle\Entity\FormField;
use Symfony\Component\Form\FormBuilderInterface;
/**
* FriendlyCaptcha form field type for SuluFormBundle
*
* @link https://friendlycaptcha.com
* @see https://github.com/sulu/SuluFormBundle
*
*/
class FriendlyCaptchaFieldType implements FormFieldTypeInterface
{
use SimpleTypeTrait;
public function getConfiguration(): FormFieldTypeConfiguration
{
return new FormFieldTypeConfiguration(
'FriendlyCaptcha',
__DIR__ . '/../../../config/form-bundle/field_friendlycaptcha.xml',
'special'
);
}
public function build(FormBuilderInterface $builder, FormField $field, string $locale, array $options): void
{
// Use in this way the friendlycaptcha bundle could maybe not exists.
$options['mapped'] = false;
$options['required'] = true;
$options['constraints'] = new FriendlyCaptchaValid();
$builder->add($field->getKey(), FriendlyCaptchaType::class, $options);
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels