My favorites | Sign in
Project Logo
                
Changes to /qt-blog/views/posts/admin_edit.ctp
r13 vs. r43   Edit
  Compare: vs.   Format:
Revision r43
Go to: 
Project members, sign in to write a code review
/qt-blog/views/posts/admin_edit.ctp   r13 /qt-blog/views/posts/admin_edit.ctp   r43
1 <?php 1 <?php
2 // var_dump($this->data); 2 // var_dump($this->data);
3 // import markup from baked template (lazy) 3 // import markup from baked template (lazy)
4 $formMarkup = new Callback( 4 $formMarkup = new Callback(
5 create_function('$view', 5 create_function('$view', '
6 'return $view->requestAction("/admin/posts/template/edit/", array("return"));' 6 return $view->requestAction("/admin/posts/template/edit/", array("return"));
7 ), $this 7 '), $this
8 ); 8 );
9 $name = substr(__FILE__, strlen(VIEWS)); 9 $name = substr(__FILE__, strlen(VIEWS));
10 $template = template($name) 10 $template = template($name)
11 // use baked template as markup source 11 // use baked template as markup source
12 ->sourceCollect($formMarkup, 'formMarkup') 12 ->sourceCollect($formMarkup, 'formMarkup')
13 ->parse() 13 ->parse()
14 ->source('formMarkup')->returnReplace() 14 ->source('formMarkup')->returnReplace()
15 ->find('fieldset:eq(1)') 15 ->find('fieldset:eq(1)')
16 ->find('.input:has(input[name*=published])') 16 ->find('.input:has(input[name*=published])')
17 ->replaceWith(' 17 ->replaceWith('
18 <div> 18 <div>
19 <label>Published</label> 19 <label>Published</label>
20 <input name="published" type="radio" value="1" /> YES 20 <input name="published" type="radio" value="1" /> YES
21 <input name="published" type="radio" value="0"/> NO 21 <input name="published" type="radio" value="0"/> NO
22 </div>') 22 </div>')
23 ->end() 23 ->end()
24 ->find('.input:has(input[name*=Tag])') 24 ->find('.input:has(input[name*=Tag])')
25 ->find('input[type=hidden]')->remove()->end() 25 ->find('input[type=hidden]')->remove()->end()
26 ->find('select')->attr('name', 'Tag')->end() 26 ->find('select')->attr('name', 'Tag')->end()
27 ->end() 27 ->end()
28 ->end() 28 ->end()
29 /* IMPORTED TEMPLATE PREPARATION */ 29 /* IMPORTED TEMPLATE PREPARATION */
30 ->find('form') 30 ->find('form')
31 // form[action] is broken like other URLs from imported template 31 // form[action] is broken like other URLs from imported template
32 ->attr('action', '/admin/posts/edit') 32 ->attr('action', '/admin/posts/edit')
33 // remove form's internal fieldset (will be readded) 33 // remove form's internal fieldset (will be readded)
34 ->find('fieldset:has(input[name=_method])')->remove()->end() 34 ->find('fieldset:has(input[name=_method])')->remove()->end()
35 ->end() 35 ->end()
36 ->plugin('CakeForms') 36 ->plugin('CakeForms')
37 ->formToCakeForm( 37 ->formToCakeForm(
38 array('Post', array('action' => 'edit')), $form) 38 array('Post', array('action' => 'edit')), $form)
39 // ->dump() 39 // ->dump()
40 ->save() 40 ->save()
41 ; 41 ;
42 require($template); 42 require($template);
Hosted by Google Code