Changeset 28338 for plugins/sfDoctrineDynamicFormRelationsPlugin
- Timestamp:
- 03/02/10 10:16:38 (3 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/sfDoctrineDynamicFormRelationsPlugin/branches/1.3/README
r28337 r28338 1 1 This plugin allows you to embed related forms in a Doctrine form class, 2 manipulate those embedded forms (i.e. add more, remove some, etc), and see 3 those relations updated when the form is processed. 2 manipulate those embedded forms using JavaScript (i.e. add more, remove some, 3 etc), and will automatically updates those relations when the form is 4 processed. 4 5 5 6 [php] … … 8 9 public function configure() 9 10 { 10 $this->embedDynamicRelation(' Books asbooks');11 $this->embedDynamicRelation('books'); 11 12 } 12 13 } 14 15 This form can now be rendered something like this, enhanced with JavaScript: 16 17 [html] 18 <form action="#" method="post"> 19 <!-- ... --> 20 <ul> 21 <?php foreach ($form['books'] as $bookFields): ?> 22 <li> 23 <table><?php echo $bookFields ?></table> 24 <a href="javascript:remove(this)">remove this book</a> 25 </li> 26 <?php endforeach ?> 27 </ul> 28 <a href="javascript:add()">add another book</a> 29 <!-- ... --> 30 </form> 31 32 Once your JavaScript is setup (which is up to you), your user can remove some 33 of the listed books and add a few more. Then, once the form is submitted, the 34 database will be updated to reflect those changes. 13 35 14 36 Limitations 15 37 ----------- 16 38 17 * The primary key of the related model must b y"id"39 * The primary key of the related model must be "id" 18 40 * The embedded form class must include an "id" field 19 41