dpka7974 2019-04-06 12:17
浏览 27

如何自定义外键的单选框的每个元素,添加id或类

I am new on Symfony, i want to customize each element of the generated radio boxes of the foreign key, i want add some id and class for each element, i can customize the full box but his elements i don't know how !!

class NiveauType extends AbstractType
{
    /**
     * {@inheritdoc}
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('niveau')
                ->add('cycle', EntityType::class, array(
                    "class" => "AdminBundle\Entity\Cycle",
                    "choice_label" => "cycle",
                    "expanded" => true, 
                    "multiple" => false,
                    "attr" => ['class' => 'radioboxes_cycle'] 
                ));
;
    }

i can reach his elements by using css, but if there any options to customize them from the FormType or By using twig to add ids to each box

<style>
    .radioboxes_cycle{
        font-size:16px; 
        display:inline-flex
    }

    .radioboxes_cycle div{
        margin:10px;
    }


</style>
<div class="modal fade" id="ajouter_niveau" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    {{ form_start(formNiveau, { 'method' : 'post', 'action': path('admin_niveau_new') }) }}
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title">Ajouter un niveau</h4>
                <button type="button" class="close" data-dismiss="modal">&times;</button>
            </div>

            <div class="modal-body">
                <div class="form-group custom-mt-form-group">
                    <label class="control-label">Cycle<span class="text-danger">*</span></label>
                </div>

                {{ form_widget(formNiveau.cycle, {'attr': {'class':'radiobox_cycle'}}) }}

                <div class="form-group custom-mt-form-group">
                    {{ form_widget(formNiveau.niveau) }}
                    <label class="control-label">Niveau<span class="text-danger">*</span></label><i class="bar"></i>
                </div>


            </div>

            <div class="modal-footer">
                <button class="btn btn-primary mr-2" type="submit">Ajouter</button>
                <button class="btn btn-dark" data-dismiss="modal">Annuler</button>
            </div>
        </div>
    </div>
    {{ form_end(formNiveau) }}
</div>

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 微信会员卡接入微信支付商户号收款
    • ¥15 如何获取烟草零售终端数据
    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?