Answer the question
In order to leave comments, you need to log in
How to override the properties of an existing field in an inherited form in a Form Component?
Symfony 6.0.
I can not find an example in the documentation or on SO - how can I override the properties of one field in an inherited form in symphony? Using form events does not seem to be a very suitable tool, making two forms in parallel from the base one is inefficient.
Example:
<?php
class ArticleFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('title', TextType::class, ['help' => 'Choose something catchy'])
->add('content', null, ['rows' => 15]);
}
}
class CustomArticleFormType extends ArticleFormType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('content', null, ['rows' => 25]);
parent::buildForm($builder, $options);
}
}
Answer the question
In order to leave comments, you need to log in
<div class="example"></div>
.example {
width: 300px;
height: 50px;
background: yellow;
cursor: pointer;
position: relative;
margin: 50px auto;
}
.example:before {
content: '';
display: block;
width: 0;
height: 5px;
background: red;
position: absolute;
left: 0;
bottom: 0;
transition: .5s;
}
.example:hover:before {
width: 100%;
}
Here are the ready made solutions. You can customize for your purposes.
Here is 1 option.
Effect No. 10, on a blue background
Here is the 2nd option.
Effect #3 Surinami
I'm not a symphony expert, but this won't work - you must first call parent::buildForm(); and then replace $builder->add(content', $builder->get('content')->getType(), $builder->get('content')->getOptions()),
and from banal LSP'shnogo - you can always inherit the class and expand the visibility of its properties.
+ one of the symphony developers said that this is an outdated way and you need to pass a builder, not a string, but it's better to talk to them yourself, I don't always understand them.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question