Permalink
Browse files

New widget to create "With selected…"

  • Loading branch information...
1 parent 714f58d commit b87023da0176c4aaa45963948a576957a242b357 @nilshoerrmann nilshoerrmann committed Feb 21, 2012
@@ -202,9 +202,7 @@ public function __viewIndex() {
))
);
- $tableActions->appendChild(Widget::Select('with-selected', $options));
- $tableActions->appendChild(Widget::Input('action[apply]', __('Apply'), 'submit'));
-
+ $tableActions->appendChild(Widget::Apply($options));
$this->Form->appendChild($tableActions);
}
@@ -91,9 +91,7 @@ public function __viewIndex(){
}
}
- $tableActions->appendChild(Widget::Select('with-selected', $options));
- $tableActions->appendChild(Widget::Input('action[apply]', __('Apply'), 'submit'));
-
+ $tableActions->appendChild(Widget::Apply($options));
$this->Form->appendChild($tableActions);
}
@@ -75,9 +75,7 @@ public function __viewIndex(){
array('delete', false, __('Delete'), 'confirm'),
);
- $tableActions->appendChild(Widget::Select('with-selected', $options));
- $tableActions->appendChild(Widget::Input('action[apply]', __('Apply'), 'submit'));
-
+ $tableActions->appendChild(Widget::Apply($options));
$this->Form->appendChild($tableActions);
}
@@ -367,9 +367,6 @@ public function __viewIndex(){
$tableActions = new XMLElement('div');
$tableActions->setAttribute('class', 'actions');
-
- $tableSelector = new XMLElement('fieldset', NULL, array('class' => 'selector'));
- $tableActions->appendChild($tableSelector);
$options = array(
array(NULL, false, __('With Selected...')),
@@ -394,9 +391,7 @@ public function __viewIndex(){
}
}
- $tableSelector->appendChild(Widget::Select('with-selected', $options));
- $tableSelector->appendChild(new XMLElement('button', __('Apply'), array('name' => 'action[apply]', 'type' => 'submit')));
-
+ $tableActions->appendChild(Widget::Apply($options));
$this->Form->appendChild($tableActions);
if($entries['total-pages'] > 1){
@@ -142,9 +142,7 @@ public function __viewIndex(){
))
);
- $tableActions->appendChild(Widget::Select('with-selected', $options));
- $tableActions->appendChild(Widget::Input('action[apply]', __('Apply'), 'submit'));
-
+ $tableActions->appendChild(Widget::Apply($options));
$this->Form->appendChild($tableActions);
}
@@ -149,9 +149,7 @@ public function __viewIndex(){
))
);
- $tableActions->appendChild(Widget::Select('with-selected', $options));
- $tableActions->appendChild(Widget::Input('action[apply]', __('Apply'), 'submit'));
-
+ $tableActions->appendChild(Widget::Apply($options));
$this->Form->appendChild($tableActions);
}
@@ -181,9 +181,7 @@ public function __viewIndex($resource_type){
$options[] = $group_attach;
$options[] = $group_detach;
- $tableActions->appendChild(Widget::Select('with-selected', $options));
- $tableActions->appendChild(Widget::Input('action[apply]', __('Apply'), 'submit'));
-
+ $tableActions->appendChild(Widget::Apply($options));
$this->Form->appendChild($tableActions);
}
@@ -585,6 +585,39 @@ private static function __SelectBuildOption($option){
}
/**
+ * Generates a XMLElement representation of a `<fieldset>` containing
+ * the "With selected…" menu. This uses the private function `__SelectBuildOption()`
+ * to build XMLElements of options given the `$options` array.
+ *
+ * @since Symphony 2.3
+ * @see toolkit.Widget::__SelectBuildOption()
+ * @param Array $options (optional)
+ * An array containing the data for each `<option>` for this
+ * `<select>`. If the array is associative, it is assumed that
+ * `<optgroup>` are to be created, otherwise it's an array of the
+ * containing the option data. If no options are provided an empty
+ * `<select>` XMLElement is returned.
+ * `
+ * array(
+ * array($value, $selected, $desc, $class, $id, $attr)
+ * )
+ * array(
+ * array('label' => 'Optgroup', 'options' = array(
+ * array($value, $selected, $desc, $class, $id, $attr)
+ * )
+ * )
+ * `
+ * @return XMLElement
+ */
+ public static function Apply(Array $options = null){
+ $fieldset = new XMLElement('fieldset', NULL, array('class' => 'apply'));
+ $fieldset->appendChild(Widget::Select('with-selected', $options));
+ $fieldset->appendChild(new XMLElement('button', __('Apply'), array('name' => 'action[apply]', 'type' => 'submit')));
+
+ return $fieldset;
+ }
+
+ /**
* Will wrap a `<div>` around a desired element to trigger the default
* Symphony error styling.
*

0 comments on commit b87023d

Please sign in to comment.