當前位置: 首頁>>代碼示例>>PHP>>正文


PHP FormFactoryInterface::has方法代碼示例

本文整理匯總了PHP中Symfony\Component\Form\FormFactoryInterface::has方法的典型用法代碼示例。如果您正苦於以下問題:PHP FormFactoryInterface::has方法的具體用法?PHP FormFactoryInterface::has怎麽用?PHP FormFactoryInterface::has使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\Form\FormFactoryInterface的用法示例。


在下文中一共展示了FormFactoryInterface::has方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __construct

 public function __construct(Request $request, $type = "form", $data = array(), $options = array())
 {
     $this->request = $request;
     $validator = Validation::createValidatorBuilder();
     if (!isset($options["attr"]["name"])) {
         $options["attr"]["thelia_name"] = $this->getName();
     }
     $builder = Forms::createFormFactoryBuilder()->addExtension(new HttpFoundationExtension());
     if (!isset($options["csrf_protection"]) || $options["csrf_protection"] !== false) {
         $builder->addExtension(new CsrfExtension(new SessionCsrfProvider($request->getSession(), isset($options["secret"]) ? $options["secret"] : ConfigQuery::read("form.secret", md5(__DIR__)))));
     }
     $translator = Translator::getInstance();
     $validator->setTranslationDomain('validators')->setTranslator($translator);
     $this->formBuilder = $builder->addExtension(new ValidatorExtension($validator->getValidator()))->getFormFactory()->createNamedBuilder($this->getName(), $type, $data, $this->cleanOptions($options));
     $this->buildForm();
     // If not already set, define the success_url field
     // This field is not included in the standard form hidden fields
     // This field is not included in the hidden fields generated by form_hidden_fields Smarty function
     if (!$this->formBuilder->has('success_url')) {
         $this->formBuilder->add("success_url", "hidden");
     }
     // The "error_message" field defines the error message displayed if
     // the form could not be validated. If it is empty, a standard error message is displayed instead.
     // This field is not included in the hidden fields generated by form_hidden_fields Smarty function
     if (!$this->formBuilder->has('error_message')) {
         $this->formBuilder->add("error_message", "hidden");
     }
     $this->form = $this->formBuilder->getForm();
 }
開發者ID:alex63530,項目名稱:thelia,代碼行數:29,代碼來源:BaseForm.php


注:本文中的Symfony\Component\Form\FormFactoryInterface::has方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。