K
K
KoRNeT46RuS2020-02-12 13:28:23
1C-Bitrix
KoRNeT46RuS, 2020-02-12 13:28:23

How to do form processing in a custom component?

I created my own component that displays a form with a submit button.

<form action="<?php echo $componentPath?>" method="POST">
    <input type="submit" name="submit" value="Submit">
</form>


I'm trying to catch the arrival of a post in the class.php file, but it doesn't work. Tell me how to do it right? I run on the manul, it doesn’t work.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
mxrf, 2020-02-12
@mxrf

$componentPath is the path to the directory, and you need to the file

M
Mikhail, 2020-02-12
@RuComMarket

what do you give in $componentPath?
you need to contact the same component by sending the form to the same page where the component is called, then you can catch it in class.php simply by checking $_POST, i.e. if the component is called from site.ru/ then we direct it to / , and not to the component folder itself

Y
Yaroslav Alexandrov, 2020-02-12
@alexyarik

Take samples of the components from the materials for exam No. 2 and train on them https://academy.1c-bitrix.ru/certification/exams.php
1)

<form class="form" method="POST" Action="<?echo $APPLICATION->GetCurPage()?>"

2) in the $_REQUEST["name"] component itself

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question