Exemplo n.º 1
0
 /**
  * @dataProvider getTypeForm
  */
 public function testTypeCreate($type)
 {
     $formFactory = new FormFactory(new ParameterDictionary(array('TYPE' => $type)));
     $form = $formFactory->create();
     $this->assertTrue($form->getBuilder() instanceof FormBuilderInterface);
     $this->assertTrue($form->getStorage() instanceof StorageInterface);
     $this->assertTrue($form->getValidator() instanceof FormValidatorInterface);
     $this->assertTrue($form->getMailer() instanceof MailerInterface);
 }
Exemplo n.º 2
0
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
if (!defined('B_PROLOG_INCLUDED') || B_PROLOG_INCLUDED !== true) {
    die;
}
use Bitrix\Main\Application;
use Bitrix\Main\Loader;
use Citfact\Form\FormFactory;
use Citfact\Form\Type\ParameterDictionary;
Loader::includeModule('citfact.form');
$app = Application::getInstance();
$params = new ParameterDictionary($arParams);
$result = new ParameterDictionary();
$formFactory = new FormFactory($params);
$form = $formFactory->create();
// Builder saves data to reduce the number of requests
if ($this->startResultCache()) {
    $arResult['BUILDER_DATA'] = $form->createBuilderData()->getBuilderData();
    $this->endResultCache();
}
$form->setBuilderData($arResult['BUILDER_DATA']);
$form->handleRequest($app->getContext()->getRequest());
if ($form->isValid()) {
    $form->save();
    // If the data is successfully preserved produce redirect
    if ($params->get('AJAX') != 'Y') {
        $redirectPath = $params->get('REDIRECT_PATH') ?: getenv('REQUEST_URI');
        LocalRedirect($redirectPath);
    }