Good day!

There was another question. There is a form on Bitrix, created through the Phoebus form module. All is well, the worm is resolved without problems. Fields customized. But one thing is not clear:

You need to assign the css class to the form itself. By default, the class itself is not created in the component template, I have not found the <form tag itself, and the crooked approach seems to me

Maybe someone faced this task ...

That's it in the layout

<form action="#" class="contact-form" novalidate="novalidate"> 

Bitrix does this

 <form name="contact_form" action="/contacts/?bitrix_include_areas=Y&amp;clear_cache=Y" method="POST" enctype="multipart/form-data"> 

How to add class = "contact-form" to the form generated by bitrix

Thank!

    5 answers 5

    In fact, everything is very simple. In the standard template you can see the variable <?=$arResult["FORM_HEADER"]?> , Which contains the opening tag "form" and two hidden service fields.

    The opening tag can be written manually:

     <form name="<?=$arResult["WEB_FORM_NAME"]?>" action="<?=POST_FORM_ACTION_URI?>" method="POST" enctype="multipart/form-data" class="contact-form" novalidate="novalidate"> 

    Hidden field containing form ID:

     <input type="hidden" name="WEB_FORM_ID" value="<?=$arParams["WEB_FORM_ID"]?>"> 

    And a hidden field containing the session ID:

     <?=bitrix_sessid_post()?> 

    As a result, you need to replace the line with the construction:

     <form name="<?=$arResult["WEB_FORM_NAME"]?>" action="<?=POST_FORM_ACTION_URI?>" method="POST" enctype="multipart/form-data" class="contact-form" novalidate="novalidate"> <input type="hidden" name="WEB_FORM_ID" value="<?=$arParams["WEB_FORM_ID"]?>"> <?=bitrix_sessid_post()?> 

    And the template is ready.

    • Good evening! Thanks for the answer, but the problem was not solved. I click to edit the component pshablon template (respectively, copied to my template). And I see two connections 1. bitrix.form and bitrix.form.result.new in the second I find that line about which you said, but when you delete, change anything in this file, nothing changes on the site .... Like that This Wrong File - BlackWidow

    To comment on 1 answer: Perhaps you have a template set in the admin settings of the form, look. And the component also has a parameter - ignore this template.

    • Yes, that's exactly it was :) I figured it out earlier, but thanks! - BlackWidow

    Write the form in the CSS file as

     form[name="contact_form"]{} 

    it is easier than a form template to edit.

      And I always did like this

       $arResult["FORM_HEADER"] = substr_replace($arResult["FORM_HEADER"], ' class="contact-form" novalidate="novalidate" ', 5, 0); 

        Wrap the shape of a diva. Assign a class to it, for example "formclass". In the stylesheet file register .formclass> form {}