E
E
Evgeny Osipov2020-05-07 16:57:25
1C-Bitrix
Evgeny Osipov, 2020-05-07 16:57:25

Why is the site body displayed instead of the form result?

Added processing to init.php

AddEventHandler("iblock", "OnAfterIBlockElementAdd", Array("wsAfterForm", "wsOnAfterResultAdd"));
    class wsAfterForm {
        function wsOnAfterResultAdd(&$arFields) {
            if ($arFields["IBLOCK_ID"] == 15) {
                global $USER;
                $USER_ID = $USER->GetID();
                $user = new CUser;
                $fields = Array(
                    "UF_CLIENT" => "1",
                );
                $user -> Update($USER_ID, $fields);
                return false; // Пробовал убирать или добавлять, не помогает
            }
        }
    }


After sending the form ID 15 to the user in the add. the UF_CLIENT field is appended with 1.
But instead of the message "You have sent your request", the body of the site is displayed, i.e. site within a site.
What am I doing wrong?
If the processing is removed, then the message about successful sending is displayed as needed.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Evgeny Osipov, 2020-05-07
@Medik18

User PetrPo in the comments helped to sort out the problem.
The form on the infoblock with AJAX, turned off AJAX and began to work as it should.

I
Ilya, 2020-05-07
@rpsv

return falseextra construction, because nothing is canceled in the after event .
The output of the message "You have sent your request" is definitely not done in this piece of code.
The body of the site is most likely displayed along with an error, see the code that is given, and check the log.
And for good, it would be nice to add a check, but is the user authorized?
Add modifiers to the method public static functionto uniquely identify it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question