index.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. $class=get_class($model);
  3. Yii::app()->clientScript->registerScript('gii.crud',"
  4. $('#{$class}_controller').change(function(){
  5. $(this).data('changed',$(this).val()!='');
  6. });
  7. $('#{$class}_model').bind('keyup change', function(){
  8. var controller=$('#{$class}_controller');
  9. if(!controller.data('changed')) {
  10. var id=new String($(this).val().match(/\\w*$/));
  11. if(id.length>0)
  12. id=id.substring(0,1).toLowerCase()+id.substring(1);
  13. controller.val(id);
  14. }
  15. });
  16. ");
  17. ?>
  18. <h1>Crud Generator</h1>
  19. <p>This generator generates a controller and views that implement CRUD operations for the specified data model.</p>
  20. <?php $form=$this->beginWidget('CCodeForm', array('model'=>$model)); ?>
  21. <div class="row">
  22. <?php echo $form->labelEx($model,'model'); ?>
  23. <?php echo $form->textField($model,'model',array('size'=>65)); ?>
  24. <div class="tooltip">
  25. Model class is case-sensitive. It can be either a class name (e.g. <code>Post</code>)
  26. or the path alias of the class file (e.g. <code>application.models.Post</code>).
  27. Note that if the former, the class must be auto-loadable.
  28. </div>
  29. <?php echo $form->error($model,'model'); ?>
  30. </div>
  31. <div class="row">
  32. <?php echo $form->labelEx($model,'controller'); ?>
  33. <?php echo $form->textField($model,'controller',array('size'=>65)); ?>
  34. <div class="tooltip">
  35. Controller ID is case-sensitive. CRUD controllers are often named after
  36. the model class name that they are dealing with. Below are some examples:
  37. <ul>
  38. <li><code>post</code> generates <code>PostController.php</code></li>
  39. <li><code>postTag</code> generates <code>PostTagController.php</code></li>
  40. <li><code>admin/user</code> generates <code>admin/UserController.php</code>.
  41. If the application has an <code>admin</code> module enabled,
  42. it will generate <code>UserController</code> (and other CRUD code)
  43. within the module instead.
  44. </li>
  45. </ul>
  46. </div>
  47. <?php echo $form->error($model,'controller'); ?>
  48. </div>
  49. <div class="row sticky">
  50. <?php echo $form->labelEx($model,'baseControllerClass'); ?>
  51. <?php echo $form->textField($model,'baseControllerClass',array('size'=>65)); ?>
  52. <div class="tooltip">
  53. This is the class that the new CRUD controller class will extend from.
  54. Please make sure the class exists and can be autoloaded.
  55. </div>
  56. <?php echo $form->error($model,'baseControllerClass'); ?>
  57. </div>
  58. <?php $this->endWidget(); ?>