/** * Create a new instance of SplitButton * @param string $name Form field name * @param string $title Title that will be displayed on the split button. * if not provided, the title will be guess from the `$name`. */ public function __construct($name, $title = null) { $args = func_get_args(); $name = array_shift($args); if ($args) { $title = array_shift($args); } // Guess the title if none provided if (!$title) { $title = self::name_to_label($name); } // Instanciate our undelying tab container $this->tab = new Tab('SplitButtonTab', $title); //Call the parent consturctor parent::__construct($name, $this->tab); // Add the same class as the _more options_ link so we can piggy back // off that logic. $this->addExtraClass('ss-ui-action-tabset action-menus ss-ui-button'); // Add any provided button. if ($args) { foreach ($args as $button) { // Make sure we only add Form Fields to our tab. $isValidArg = is_object($button) && !$button instanceof FormField; if (!$isValidArg) { user_error('SplitButton::__construct(): Parameter not a valid FormField instance', E_USER_ERROR); } $this->tab->push($button); } } // Define a custom spread sheet so we can style our button. Requirements::css(EXCELEXPORT_DIR . '/css/splitbutton.css'); }