1. Go to this page and download the library: Download aidsoul/bitrix-form 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/ */
aidsoul / bitrix-form example snippets
namespace AidSoul\Bitrix\Form;
use Bitrix\Main\UserTable;
use Respect\Validation\Validator;
use Bitrix\Iblock\Elements\ElementRequestFormTable;
/**
* Request
* @author AidSoul <[email protected]>
*/
class Request extends Form
{
/**
* Массив для работы с почтой
*
* @var array
*/
protected array $mail = [
'eventType' => 'REQUEST_FORM',
'mailTemplateId' => 89
];
protected array $modalArr = [
'title' => 'Заявка отправлена!',
'message' => 'Мы ответим Вам в ближайшее время'
];
/**
* Поля текущей формы
*
* @var array
*/
protected array $formFields = [
'email' => [
'name' => 'E-mail',
'name', 'Строка поля "Имя", должна содержать от 2 до 45 символов');
}
$this->cleanFields['NAME'] = $name;
}
/**
* Возвращает массив, который доступен в шаблоне
* $arResult['DATA']
*
* @return array
*/
public function formDataAction(): array
{
$table = getClassByCodeApi($this->formData['API_CODE'] ?? 'RequestForm');
return $table::query()
->setSelect([
'ID',
'NAME',
'CODE',
'SUBTITLE_' => 'SUBTITLE',
'IMAGE_' => 'IMAGE',
])
->setOrder(['SORT' => 'ASC'])
->setFilter(['=CODE' => $this->formData['ELEMENT_CODE']])
->setCacheTtl(53456)->fetch();
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.