msvdev / bitrix-extension-forms
Bitrix symfony forms
Installs: 21
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Type:bitrix-extension
Requires
- msvdev/bitrix-extension-component: ^1
- symfony/finder: ^4.1
- symfony/form: ^3.4
- symfony/templating: ^3.4
- symfony/validator: ^3.4
README
Установка composer require msvdev/bitrix-extension-forms
Пример
<?php namespace Components\User\Login; use Modules\User\Entities\Login; use Modules\User\Forms\LoginType; use Msvdev\Bitrix\Forms\Form; class Component extends \Msvdev\Bitrix\Component\Component { public function executeComponent() { global $APPLICATION; global $USER; $entity = new Login($USER); $symfonyForm = new Form($this); $form = $symfonyForm->getFormBuilder()->create(LoginType::class, $entity); $form->handleRequest(); if ($this->request->isAjaxRequest() && $form->isSubmitted()) { $APPLICATION->RestartBuffer(); $result = [ 'result' => false, 'errors' => [], ]; if($form->isValid()){ $entity->auth(); $result['result'] = true; } else { // Get ajax errors $result['errors'] = $symfonyForm->getErrorsArray($form->getErrors(true)); } echo json_encode($result); die(); } $this->arResult['formView'] = $form->createView(); $this->arResult['entity'] = $entity; $this->includeComponentTemplate(); } }