[Pieforms-commit] SF.net SVN: pieforms: [6] pieforms/src/pieform/elements/cancel.php
Status: Alpha
Brought to you by:
oracleshinoda
From: <ora...@us...> - 2006-11-18 10:26:52
|
Revision: 6 http://svn.sourceforge.net/pieforms/?rev=6&view=rev Author: oracleshinoda Date: 2006-11-18 02:26:49 -0800 (Sat, 18 Nov 2006) Log Message: ----------- Only allow cancel buttons to use 'value' for their value, rather than potentially the request. Use Pieform::hsc Modified Paths: -------------- pieforms/src/pieform/elements/cancel.php Modified: pieforms/src/pieform/elements/cancel.php =================================================================== --- pieforms/src/pieform/elements/cancel.php 2006-11-18 09:51:57 UTC (rev 5) +++ pieforms/src/pieform/elements/cancel.php 2006-11-18 10:26:49 UTC (rev 6) @@ -26,24 +26,29 @@ /** * Renders a "cancel" button. Custom buttons are rendered nearly the same as - * normal submit buttons, only their name is changed (for use by the Pieform class - * internally). + * normal submit buttons, only their name is changed (for use by the Pieform + * class internally). * - * @param array $element The element to render + * @param array $element The element to render * @param Pieform $form The form to render the element for - * @return string The HTML for the element + * @return string The HTML for the element */ function pieform_render_cancel($element, Pieform $form) { + if (!isset($element['value'])) { + throw new PieformException('Cancel elements must have a value'); + } + $attributes = Pieform::element_attributes($element); $attributes = preg_replace('/name="(.*)"/', 'name="cancel_$1"', $attributes); $attributes = preg_replace('/id="(.*)"/', 'id="cancel_$1"', $attributes); return '<input type="submit"' . $attributes - . ' value="' . hsc($form->get_value($element)) . '">'; + . ' value="' . Pieform::hsc($element['value']) . '">'; } // @todo how to support cancel buttons for ajax post? Possibly do a full post regardless... // or allow the user to specify a javascript function to run... it could do document.location= +// @todo also, cancel buttons don't need to be sent around via js... maybe make this return empty string function pieform_get_value_js_cancel($element, Pieform $form) { $formname = $form->get_name(); $name = $element['name']; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |