SHARE
TWEET

Untitled

a guest Jul 22nd, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?
  2. // include core
  3.  
  4. /*
  5.  * создает новую форму и вопросы всех возможных типов
  6.  * */
  7. // у формы обязательно должен быть хоть один статус и один из них обязательно по умолчанию
  8. // иначе не сохранить результат в админке или через стд компоненты
  9. $status = new \Webform\Install\StatusBuilder();
  10. $status->add("Первый", true);
  11. $status->add("Второй");
  12. $status->add("Третий");
  13. $n = rand(0, 100);
  14. $formId = \Webform\Install\Installer::addForm("test $n", "test_" . $n, $status);
  15. $questions = new \Webform\Install\QuestionBuilder();
  16. $questions->addStringQuestion("string1", "s1");
  17. $questions->addDateQuestion("date1", "d1");
  18. $enum = new Webform\Install\EnumQuestionAnswerBuilder();
  19. $enum->add("enum var 1", "e1");
  20. $enum->add("enum var 2", "e2");
  21. $questions->addEnumQuestion("enum 1", "en1", $enum);
  22. $questions->addUrlQuestion("url 1", "u1");
  23. $enum = new Webform\Install\EnumQuestionAnswerBuilder("radio");
  24. $enum->add("radio val 1", "r1");
  25. $enum->add("radio val 2", "r2");
  26. $questions->addEnumQuestion("r1", "r1", $enum);
  27. $enum = new Webform\Install\EnumQuestionAnswerBuilder("dropdown");
  28. $enum->add("dropdown val 1", "d1");
  29. $enum->add("dropdown val 2", "d2");
  30. $questions->addEnumQuestion("dropdown 1", "dr1", $enum);
  31. $questions->addHiddenQuestion("hidden 1", "h1");
  32. $questions->addEmailQuestion("email1", "e1");
  33. $questions->addFileQuestion("file 1", "f1");
  34. $questions->addPasswordQuestion("password 1", "p1");
  35. \Webform\Install\Installer::addQuestions($formId, $questions);
  36. \Webform\Install\Installer::addEmailTpl($formId);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top