Changeset 1154:e85c1417b8a4 for inc/admin/class.dc.form.php
- Timestamp:
- 04/09/13 09:08:48 (12 years ago)
- Branch:
- twig
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inc/admin/class.dc.form.php
r1153 r1154 20 20 class dcFormNode extends Twig_Node 21 21 { 22 public function __construct($name,Twig_NodeInterface $body,$ lineno,$tag=null)23 { 24 parent::__construct(array('body' => $body),array('name' => $name ),$lineno,$tag);22 public function __construct($name,Twig_NodeInterface $body,$attr,$lineno,$tag=null) 23 { 24 parent::__construct(array('body' => $body),array('name' => $name, 'attr' => $attr),$lineno,$tag); 25 25 } 26 26 … … 36 36 $compiler 37 37 ->write("\$context['dc_form']->beginForm(") 38 ->subcompile($this->getAttribute('name')) 38 ->subcompile($this->getAttribute('name')); 39 if ($this->getAttribute('attr') !== null) { 40 $compiler 41 ->write(',') 42 ->subcompile($this->getAttribute('attr')); 43 } 44 $compiler 39 45 ->write(");\n"); 40 46 $compiler … … 56 62 $stream = $this->parser->getStream(); 57 63 $name = $this->parser->getExpressionParser()->parseExpression(); 64 $attr = null; 65 if ($stream->test(Twig_Token::NAME_TYPE, 'with')) { 66 $stream->next(); 67 $attr = $this->parser->getExpressionParser()->parseExpression(); 68 } 58 69 $stream->expect(Twig_Token::BLOCK_END_TYPE); 59 70 $body = $this->parser->subparse(array($this,'decideBlockEnd'),true); 60 71 $stream->expect(Twig_Token::BLOCK_END_TYPE); 61 72 62 return new dcFormNode($name,$body,$ token->getLine(),$this->getTag());73 return new dcFormNode($name,$body,$attr,$token->getLine(),$this->getTag()); 63 74 } 64 75 … … 219 230 } 220 231 221 public function beginForm($name )232 public function beginForm($name,$attr=array()) 222 233 { 223 234 if (isset($this->forms[$name])) { 224 235 $this->currentForm = $this->forms[$name]; 225 $this->currentForm->begin( );236 $this->currentForm->begin($attr); 226 237 } 227 238 else { … … 381 392 } 382 393 } 383 public function begin() 384 { 385 echo sprintf( 386 '<form%s method="%s" action="%s">', 387 empty($this->id) ? '' : ' id="'.$this->id.'"', 388 $this->method, 389 $this->action 390 ); 394 public function begin($attr=array()) 395 { 396 $attr['method'] = $this->method; 397 $attr['action'] = $this->action; 398 if (!empty($this->id)) { 399 $attr['id'] = $this->id; 400 } 401 $this->core->tpl->getExtension('dc_form')->renderWidget( 402 'beginform', 403 $attr); 391 404 } 392 405
Note: See TracChangeset
for help on using the changeset viewer.