加载中...

7.6 添加表单 AlbumForm


添加文件:/module/Album/src/Album/Form/AlbumForm.php,具体内容如下:

  1. namespace Album\Form;
  2. use Zend\Form\Form;
  3. class AlbumForm extends Form{
  4. public function __construct($name=null)
  5. {
  6. parent::__construct('album');
  7. $this->setAttribute('method', 'post');
  8. $this->add(array(
  9. 'name'=>'id',
  10. 'type'=>'Hidden'
  11. ));
  12. $this->add(array(
  13. 'name'=>'title',
  14. 'type'=>'Text',
  15. 'options'=>array(
  16. 'label'=>'Title'
  17. ),
  18. ));
  19. $this->add(array(
  20. 'name'=>'artist',
  21. 'type'=>'Text',
  22. 'options'=>array(
  23. 'label'=>'Artist'
  24. ),
  25. ));
  26. $this->add(array(
  27. 'name'=>'submit',
  28. 'type'=>'submit',
  29. 'attributes'=>array(
  30. 'value'=>'Go',
  31. 'id'=>'submit'
  32. ),
  33. ));
  34. }
  35. }

还没有评论.