You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

62 lines
2.3 KiB

  1. <?php
  2. /**
  3. * Class helper_plugin_bureaucracy_fieldselect
  4. *
  5. * Creates a dropdown list
  6. */
  7. class helper_plugin_bureaucracy_fieldselect extends helper_plugin_bureaucracy_field {
  8. protected $mandatory_args = 3;
  9. /**
  10. * Arguments:
  11. * - cmd
  12. * - label
  13. * - option1|option2|etc
  14. * - ^ (optional)
  15. *
  16. * @param array $args The tokenized definition, only split at spaces
  17. */
  18. public function initialize($args) {
  19. $this->init($args);
  20. $this->opt['args'] = array_map('trim', explode('|',array_shift($args)));
  21. $this->standardArgs($args);
  22. if (!isset($this->opt['value']) && isset($this->opt['optional'])) {
  23. array_unshift($this->opt['args'],' ');
  24. }
  25. }
  26. /**
  27. * Render the field as XHTML
  28. *
  29. * Outputs the represented field using the passed Doku_Form object.
  30. * Additional parameters (CSS class & HTML name) are passed in $params.
  31. *
  32. * @params array $params Additional HTML specific parameters
  33. * @params Doku_Form $form The target Doku_Form object
  34. * @params int $formid unique identifier of the form which contains this field
  35. */
  36. public function renderfield($params, Doku_Form $form, $formid) {
  37. $this->_handlePreload();
  38. if(!$form->_infieldset){
  39. $form->startFieldset('');
  40. }
  41. if ($this->error) {
  42. $params['class'] = 'bureaucracy_error';
  43. }
  44. $params = array_merge($this->opt, $params);
  45. $form->addElement(call_user_func_array('form_makeListboxField',
  46. $this->_parse_tpl(
  47. array(
  48. '@@NAME@@',
  49. $params['args'],
  50. '@@VALUE|' . $params['args'][0] . '@@',
  51. '@@DISPLAY@@',
  52. '@@ID@@',
  53. '@@CLASS@@'
  54. ),
  55. $params
  56. )));
  57. }
  58. }