PHP code example of proklung / bitrix-webform-bundle
1. Go to this page and download the library: Download proklung/bitrix-webform-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Prokl\BitrixWebformBundle\Services\FormProcessor;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class FormController extends AbstractController
{
public function action(Request $request, FormProcessor $processor) : Response
{
$params = $request->request->all();
$result = $processor->setFormCode('TESTING_FORM')
->setData($params)
->processForm();
return new Response(['id_answer' => $result]);
}
}
use Prokl\BitrixWebformBundle\Services\FormSearcher;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class FormController extends AbstractController
{
public function action(Request $request, FormSearcher $searcher) : Response
{
/**
$params = [
'NAME' => '1111',
'EMAIL' => '[email protected]',
];
*/
$params = $request->request->all();
$result = $searcher->addFilter($params)
->setIdForm(8) // Допустимо использовать setFormCode('Символьный код формы')
->exist();
return new Response(['already_exists' => $result]);
}
}