Guest User

Untitled

a guest
Oct 18th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. <?php
  2. class audWidgetFormDoctrineChoiceWithAll extends sfWidgetFormDoctrineChoice
  3. {
  4. protected function configure($options = array(), $attributes = array())
  5. {
  6. $this->addOption('add_all', false);
  7. parent::configure($options, $attributes);
  8.  
  9. }
  10.  
  11. public function render($name, $value = null, $attributes = array(), $errors = array())
  12. {
  13. $js = '';
  14. if ($this->getOption('add_all')) {
  15. $js = sprintf(<<<EOF
  16. <script type="text/javascript">
  17. $(document).ready(function() {
  18. $('#%s option').eq(1).before($('<option>').attr('value', '').html('%s'));
  19. });
  20. </script>
  21. EOF
  22. , $this->generateId($name),
  23. $this->getOption('add_all')
  24. );
  25.  
  26. }
  27.  
  28. return $js . parent::render($name, $value, $attributes, $errors);
  29. }
  30.  
  31. }
Add Comment
Please, Sign In to add comment