* @var boolean
*/
var $use_add_widget;
+ /**
+ * Indicates if the Delete widget should be included
+ * with edit lists.
+ *
+ * @var boolean
+ */
+ var $use_delete_widget;
/**
* text displayed to the user
*
$this->comment = '';
$this->layout_type = 0;
$this->use_add_widget = TRUE;
+ $this->use_delete_widget = TRUE;
$this->aExtraAttribs = array();
$this->post_script = '';
$this->use_add_widget = $use_add_widget;
}
+ /* Set the "use delete widget" value for this option. */
+ function setUseDeleteWidget($use_delete_widget) {
+ $this->use_delete_widget = $use_delete_widget;
+ }
+
/**
* Set the layout type for this option.
* @param int $layout_type
//FIXME: $this->aExtraAttribs probably should only be used in one place
$oTemplate->assign('input_widget', addInput('add_' . $this->name, '', 38, 0, $this->aExtraAttribs));
$oTemplate->assign('use_input_widget', $this->use_add_widget);
+ $oTemplate->assign('use_delete_widget', $this->use_delete_widget);
$oTemplate->assign('trailing_text', $this->trailing_text);
$oTemplate->assign('possible_values', $this->possible_values);
// delete selected elements if needed
//
- if (is_array($option->new_value)
+ if ((isset($option->use_delete_widget) && $option->use_delete_widget)
+ && is_array($option->new_value)
&& sqGetGlobalVar('delete_' . $option->name, $ignore, SQ_POST))
$option->possible_values = array_diff($option->possible_values, $option->new_value);
$next_option->setUseAddWidget($optset['use_add_widget']);
}
+ /* If provided, set the use_delete_widget value for this option. */
+ if (isset($optset['use_delete_widget'])) {
+ $next_option->setUseDeleteWidget($optset['use_delete_widget']);
+ }
+
/* If provided, set the comment for this option. */
if (isset($optset['comment'])) {
$next_option->setComment($optset['comment']);
* string $input_widget A preconstructed input text box used
* for adding new elements to the edit list
* boolean $use_input_widget Whether or not to present the $input_widget
- * string $select_widget A preconstructed input text box used
- * string $checkbox_widget A preconstructed input text box used
+ * boolean $use_delete_widget Whether or not to present the $checkbox_widget
+ * string $select_widget A preconstructed select widget containing
+ * all the elements in the list
+ * string $checkbox_widget A preconstructed checkbox used for deleting
+ * elements from the edit list
* string $trailing_text Any text given by the caller to be displayed
* after the edit list input
* array $possible_values The original list of options in the edit list,
if ($use_input_widget)
echo _("Add") . ' ' . $input_widget . '<br />';
-echo $select_widget
- . '<br />' . $checkbox_widget . ' <label for="delete_' . $name . '">'
- . _("Delete Selected") . '</label>';
+echo $select_widget;
+
+if (!empty($possible_values) && $use_delete_widget)
+ echo '<br />' . $checkbox_widget . ' <label for="delete_' . $name . '">'
+ . _("Delete Selected") . '</label>';
* string $input_widget A preconstructed input text box used
* for adding new elements to the edit list
* boolean $use_input_widget Whether or not to present the $input_widget
- * string $select_widget A preconstructed input text box used
- * string $checkbox_widget A preconstructed input text box used
+ * boolean $use_delete_widget Whether or not to present the $checkbox_widget
+ * string $select_widget A preconstructed select widget containing
+ * all the elements in the list
+ * string $checkbox_widget A preconstructed checkbox used for deleting
+ * elements from the edit list
* string $trailing_text Any text given by the caller to be displayed
* after the edit list input
* array $possible_values The original list of options in the edit list,
echo '</table>';
-if (!empty($possible_values))
+if (!empty($possible_values) && $use_delete_widget)
echo $checkbox_widget . ' <label for="delete_' . $name . '">'
. _("Delete Selected") . '</label>';