1<!DOCTYPE html> 2<html> 3<head> 4 <meta charset="utf-8"> 5 <meta http-equiv="X-UA-Compatible" content="chrome=1"> 6 7 8 9 <title> 10 Symfony ç¬è®°3--表å | spkinger's blog 11 </title> 12 13 <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> 14 15 <meta name="author" content="spkinger"> 16 17 18 19 <meta name="description" content="Symfonyç表åé¨å"> 20<meta property="og:type" content="article"> 21<meta property="og:title" content="Symfony ç¬è®°3--表å | spkinger's blog"> 22<meta property="og:url" content="http://spkinger.github.io/2016/07/28/symfony-form/index.html"> 23<meta property="og:site_name" content="spkinger's blog"> 24<meta property="og:description" content="Symfonyç表åé¨å"> 25<meta property="og:updated_time" content="2016-07-28T09:08:45.286Z"> 26<meta name="twitter:card" content="summary"> 27<meta name="twitter:title" content="Symfony ç¬è®°3--表å | spkinger's blog"> 28<meta name="twitter:description" content="Symfonyç表åé¨å"> 29 30 31 32 <link rel="icon" type="image/x-icon" href="/favicon.png"> 33 34 <link rel="stylesheet" href="/css/uno.css"> 35 <link rel="stylesheet" href="/css/highlight.css"> 36 <link rel="stylesheet" href="/css/archive.css"> 37 <link rel="stylesheet" href="/css/china-social-icon.css"> 38 39</head> 40<body> 41 42 <span class="mobile btn-mobile-menu"> 43 <i class="icon icon-list btn-mobile-menu__icon"></i> 44 <i class="icon icon-x-circle btn-mobile-close__icon hidden"></i> 45 </span> 46 47 48 49<header class="panel-cover panel-cover--collapsed"> 50 51 52 <div class="panel-main"> 53 54 55 <div class="panel-main__inner panel-inverted"> 56 <div class="panel-main__content"> 57 58 59 60 <h1 class="panel-cover__title panel-title"><a href="/" title="link to homepage">spkinger's blog</a></h1> 61 <hr class="panel-cover__divider" /> 62 63 64 65 <div class="navigation-wrapper"> 66 67 <nav class="cover-navigation cover-navigation--primary"> 68 <ul class="navigation"> 69 70 71 72 <li class="navigation__item"><a href="/#blog" title="" class="blog-button">é¦é¡µ</a></li> 73 74 75 <li class="navigation__item"><a href="/about" title="" class="">å ³äº</a></li> 76 77 78 <li class="navigation__item"><a href="/archive" title="" class="">彿¡£</a></li> 79 80 81 </ul> 82 </nav> 83 84 <!-- ---------------------------- 85To add a new social icon simply duplicate one of the list items from below 86and change the class in the <i> tag to match the desired social network 87and then add your link to the <a>. Here is a full list of social network 88classes that you can use: 89 90 icon-social-500px 91 icon-social-behance 92 icon-social-delicious 93 icon-social-designer-news 94 icon-social-deviant-art 95 icon-social-digg 96 icon-social-dribbble 97 icon-social-facebook 98 icon-social-flickr 99 icon-social-forrst 100 icon-social-foursquare 101 icon-social-github 102 icon-social-google-plus 103 icon-social-hi5 104 icon-social-instagram 105 icon-social-lastfm 106 icon-social-linkedin 107 icon-social-medium 108 icon-social-myspace 109 icon-social-path 110 icon-social-pinterest 111 icon-social-rdio 112 icon-social-reddit 113 icon-social-skype 114 icon-social-spotify 115 icon-social-stack-overflow 116 icon-social-steam 117 icon-social-stumbleupon 118 icon-social-treehouse 119 icon-social-tumblr 120 icon-social-twitter 121 icon-social-vimeo 122 icon-social-xbox 123 icon-social-yelp 124 icon-social-youtube 125 icon-social-zerply 126 icon-mail 127 128--------------------------------> 129 130<!-- add social info here --> 131 132 133 134 </div> 135 136 </div> 137 138 </div> 139 140 <div class="panel-cover--overlay"></div> 141 </div> 142</header> 143 144 <div class="content-wrapper"> 145 <div class="content-wrapper__inner entry"> 146 147 148<article class="post-container post-container--single"> 149 150 <header class="post-header"> 151 152 <h1 class="post-title">Symfony ç¬è®°3--表å</h1> 153 154 155 156 </header> 157
158 <section id="post-content" class="article-content post"> 159 <p>#9.表åçæ</p> 160<p>####(1).åºæ¬ççæ</p> 161<pre><code>#æ§å¶å¨ä¸ 162public function indexAction($name, Request $request) 163{ 164 $user = new User(); 165 $form = $this->createFormBuilder($user) 166 ->add('email','email',array('label'=>'é®ç®±')) 167 ->add('password') 168 ->add('age') 169 ->add('æäº¤','submit') 170 ->getForm(); 171 172 $form->handleRequest($request); 173 174 if($form->isValid()){ 175 $em = $this->getDoctrine()->getManager(); 176 $em->persist($user); 177 $em->flush(); 178 } 179 180 return array('content'=>$name, 'form'=>$form->createView()); 181} 182#è§å¾ä¸ 183{{ form(form) }} 184</code></pre><p>####(2).FORM模æ¿çä¿®æ¹</p> 185<pre><code>{ { form(form) } }坿©å±ä¸º 186 187{ { form_start(form) } } 188{ { form_widget(form) } } 189{ { form_end(form) } } 190 191{ { form_start(form) } } 192<!--è¿éæå¤ä¸ª--> 193{ { form_label(form.email) } } 194{ { form_errors(form.email) } } 195{ { form_widget(form.email) } } 196 197{ { form_end(form) } } 198</code></pre><p>####(3).é项模æ¿çä¿®æ¹</p> 199<pre><code>#å¯ä¿®æ¹ä¸é¢è¿ç§æ¯ä¸ªåå 200{ % block email_widget -% } 201 { % set type = type|default('email') -% } 202 { { block('form_widget_simple') } } 203{ % endblock email_widget % } 204 205#对模æ¿çä¿®æ¹å¯ä»¥æ¾å°view/form/my_form_widget.html.twigç¶åéè¿ä¸é¢ä»£ç å¼å ¥ 206{ % form_theme from ['xxxBundle:Form:my_form_widget.html.twig'] % } 207</code></pre> 208 </section> 209 210 211 212</article> 213 214 215 <footer class="footer"> 216 217 <span class="footer__copyright">© 2014-2015. | ç±<a href="https://hexo.io/">Hexo</a>强åé©±å¨ | 主é¢<a href="https://github.com/someus/huno">Huno</a></span> 218 219</footer> 220 </div> 221 </div> 222 223 <!-- js files --> 224
224<script src="/js/jquery.min.js"></script>
224 225
225<script src="/js/main.js"></script>
225 226
226<script src="/js/scale.fix.js"></script>
226 227 228 229 230 231
231<script type="text/javascript" src="//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
231 232
232<script type="text/javascript"> 233 $(document).ready(function(){ 234 MathJax.Hub.Config({ 235 tex2jax: {inlineMath: [['[latex]','[/latex]'], ['\\(','\\)']]} 236 }); 237 }); 238 </script>
238 239 240 241 242 243
243<script src="/js/awesome-toc.min.js"></script>
243 244
244<script> 245 $(document).ready(function(){ 246 $.awesome_toc({ 247 overlay: true, 248 contentId: "post-content", 249 }); 250 }); 251 </script>
251 252 253 254 255 256 <!--kill ie6 --> 257<!--[if IE 6]> 258
258<script src="//letskillie6.googlecode.com/svn/trunk/2/zh_CN.js"></script>
258 259<![endif]--> 260 261</body> 262</html>
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.