简体   繁体   English

如何在控制器上的Form made Button中填充

[英]How can I do padding in Form made Button on my Controller

I wanna make a small padding in my Button so i can divide the Send Button the form my Mensagem box. 我想在我的按钮中做一个小填充,这样我就可以将发送按钮分成我的Mensagem框。

Here is a pic for more details: 这是一张有关详细信息的图片:

在此输入图像描述

I already tried making a style for it didnt seem work. 我已经尝试过为它制作一种风格似乎没什么用。

If there is any other code i should provide, ill edit. 如果我应该提供任何其他代码,生病编辑。

Here is the function that makes the Whole form 这是制作整体形式的功能

public function contactus(Request $request)
            {
                //Formulário para enviar dados com estilos do w3 css    
                $mensagem_default = ['message' => ''];//mensagem default a ser enviada
                //cria um form type
                $form = $this->createFormBuilder($mensagem_default)
                //Adiciona o campo nome
                ->add('name', TextType::class, [
                    'label'=> 'O seu Nome', 'attr'=>[ 'class' => 'form-control'], 'required' => false 
                ])
                //adiciona a empresa   
                ->add('enterprise', TextType::class, [
                    'label'=> 'A sua Empresa', 'attr'=>[ 'class' => 'form-control'], 'required' => false 
                ])

                //adiciona o telemovel  
                ->add('phone', TextType::class, [
                    'label'=> 'O seu Telemovel', 'attr'=>[ 'class' => 'form-control'], 'required' => false 
                ])

                //Adiciona o campo email
                ->add('email', TextareaType::class, [
                    'label'=> 'Email', 'attr'=>[ 'class' => 'form-control'], 'required' => false
                ])

                //adiciona o assunto  
                ->add('subject', TextType::class, [
                    'label'=> 'Assunto', 'attr'=>[ 'class' => 'form-control'], 'required' => false 
                ])

                //Adiciona o campo mensagem
                ->add('message', TextareaType::class, [
                    'label'=> 'Mensagem', 'attr'=>[ 'class' => 'form-control'], 'required' => false
                ])
                //Adiciona o campo botão enviar dados
                ->add('send', SubmitType::class, [
                     'attr'=>['class' => 'btn btn-primary']
                ])
                ->getForm();

                // Renderiza os arreio para a página principal e Renderiza o formulario para o body
                return $this -> render('contactus.html.twig', ['page'=> 'contactus', 'form'=> $form ->createView(),]);
                }

It looks like you are using bootstrap. 看起来你正在使用bootstrap。 If so, you can add a bootstrap utility class for padding .p-1 .p-2 .p-3 . 如果是这样,您可以为padding .p-1 .p-2 .p-3添加一个bootstrap实用程序类。 But, what I think you really want is a margin above the button, for that you can use .mt-1 , I have had problems with the .mt- classes and usually end up using .m-1 combined with .ml-0 to keep the left margin at zero. 但是,我认为你真正想要的是按钮上方的边距 ,因为你可以使用.mt-1 ,我遇到了.mt-类的问题,并且通常最终使用.m-1.ml-0结合使用保持左边距为零。 See here for reference. 请参阅此处以供参考。

->add('send', SubmitType::class, [
    'attr'=>['class' => 'btn btn-primary m-1 ml-0']
])

Alternatively, you should also be able to add an inline style declaration like so: 或者,您还应该能够添加内联样式声明,如下所示:

->add('send', SubmitType::class, [
    'attr'=>[
        'class' => 'btn btn-primary',
        'style' => 'margin-top:1em;',
    ]
])

You can also use customized form rendering in your template, see How to Customize Form Rendering 您还可以在模板中使用自定义表单呈现,请参阅如何自定义表单呈现

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM