sfFormButtonsPlugin - 0.4.0

Lets you use button tags instead input of ones in common template design cases.

You are currently browsing
the website for symfony 1

Visit the Symfony2 website

« Back to the Plugins Home


Forgot your password?
Create an account



advanced search
Information Readme Dependencies Releases Changelog Contribute
Show source

Note this

This plugin was tested in Symfony 1.4.8. If anyone wants to test it in prior versions and contribute with any modification can email me freely.


The sfFormButtonsPlugin plugin provides a helper that lets you use button tags instead of input ones in common template design cases.


<?php use_helper('FormButtons') ?>


Returns an XHTML compliant <button> tag with type="submit".

echo submit_button_tag();
=> <button type="submit" name="commit">Save changes</button>

echo submit_button_tag('Save this now', array('class' => 'submit'));
=> <button type="submit" name="commit" class="submit">Save this now</button>


Returns an XHTML compliant <button> tag with type="button". By default, this helper creates a button tag with a name of $value replacing spaces with underscores, but you can avoid it specifying it in the $options parameter.

echo button_tag('My Button'); // name = my_button_btn
=> <button type="button" name="my_button_btn">My Button</button>

echo button_tag('Update Record', array('name' => 'my_update_button'));
=> <button type="button" name="my_update_button">Update Record</button>


Returns a button that'll trigger a javascript function using the onclick handler and return false after the fact.

echo button_to_js('Greeting', "alert('Hello world!')");
=> <button name="greeting_btn" onclick="alert('Hello world!'); return false;" type="button">Greeting</button>


Creates a <button> button tag of the given name pointing to a routed URL based on the module/action passed as argument and the routing configuration.

echo button_to_url('Delete this page', 'my_module/my_action');
=> <button onclick="document.location.href='/my_module/my_action';" type="button" name="delete_this_page_btn">Delete this page</button>


Creates a <button> button tag with the given content and value and an AJAX XHttpRequest-Method to submit the form.

echo submit_button_to_remote('Save', 'save', array(
 'url' => "module/action",
 'update' => "SiteElem"
=> <button type="submit" value="save" onClick="new Ajax.Updater('SiteElem', '/path/to/module/action', {asynchronous:true, evalScripts:false, parameters:Form.serialize(this.form)}); return false;">Save</button>


  • absolute - if set to true, the helper outputs an absolute URL
  • query_string - to append a query string (starting by ?) to the routed url
  • anchor - to append an anchor (starting by #) to the routed url
  • confirm - displays a javascript confirmation alert when the button is clicked
  • popup - if set to true, the button opens a new browser window
  • post - if set to true, the button submits a POST request instead of GET (caution: do not use inside a form)


Creates a <button> button tag with the given content and a jQuery call to a remote function.

echo button_to_remote_jq('Delete Item', array(
  'url' => 'module/action?id='.$id,
  'confirm' => 'Sure?',
  'success' => '$('#someHtmlId').remove()',


  • success - JavaScript function to call on successfull remote request. (jQuery.remove() for example.)
  • url - remote URL to call using jQuery and XmlHttpRequest
  • confirm - if set, display a confirmation message prior to remove.