symfony API

JavascriptBaseHelper Functions

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


« Back to API menu

1.2 API OpenSearch

Packages

You are currently browsing the symfony API for the 1.2 version. Switch to:
This version of symfony is not maintained anymore.
If some of your projects still use this version, consider upgrading as soon as possible.

JavascriptBaseHelper.

Function Summary

  • string array_or_string_for_javascript((option) $option)
    converts the given PHP array or string to the corresponding javascript array or string.
  • string boolean_for_javascript($bool)
    converts the given PHP boolean to the corresponding javascript boolean.
  • button_to_function($name, $function, $html_options = array())
    Returns a button that'll trigger a javascript function using the onclick handler and return false after the fact.
  • end_if_javascript()
    Mark the end of a block that should only be shown in the browser if JavaScript is switched on.
  • end_javascript_tag()
  • if_javascript()
    Mark the start of a block that should only be shown in the browser if JavaScript is switched on.
  • javascript_cdata_section($content)
  • javascript_tag($content = null)
    Returns a JavaScript tag with the '$content' inside. If no content is passed, it works as the slot() method and will output everythin between
  • link_to_function($name, $function, $html_options = array())
    Returns a link that'll trigger a javascript function using the onclick handler and return false after the fact.
  • string options_for_javascript($options)
    converts the the PHP options array into a javscript array

Function Details

  • (string) array_or_string_for_javascript ((option) $option) Browse code

    $option (typically from option array)

    converts the given PHP array or string to the corresponding javascript array or string.


    javascript strings need to be single quoted.

    returns javascript string or array equivalent

  • (string) boolean_for_javascript ($bool) Browse code

    $bool (typically from option array)

    converts the given PHP boolean to the corresponding javascript boolean.


    booleans need to be true or false (php would print 1 or nothing).

    returns javascript boolean equivalent

  • button_to_function ($name, $function, $html_options = array()) Browse code

    $name
    $function
    $html_options

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


    Examples: <?php echo button_to_function('Greeting', "alert('Hello world!')") ?>

  • end_if_javascript () Browse code

    Mark the end of a block that should only be shown in the browser if JavaScript is switched on.

  • end_javascript_tag () Browse code

  • if_javascript () Browse code

    Mark the start of a block that should only be shown in the browser if JavaScript is switched on.

  • javascript_cdata_section ($content) Browse code

    $content

  • javascript_tag ($content = null) Browse code

    $content

    Returns a JavaScript tag with the &apos;$content&apos; inside. If no content is passed, it works as the slot() method and will output everythin between


    javascript_tag() and end_javascript_tag(), Example: <?php echo javascript_tag("alert('All is good')") ?> => <script type="text/javascript">alert('All is good')</script> <?php javascript_tag() ?>alert('All is good')<?php end_javascript_tag() ?>

  • link_to_function ($name, $function, $html_options = array()) Browse code

    $name
    $function
    $html_options

    Returns a link that&apos;ll trigger a javascript function using the onclick handler and return false after the fact.


    Examples: <?php echo link_to_function('Greeting', "alert('Hello world!')") ?> <?php echo link_to_function(image_tag('delete'), "do_delete()", array('confirm' => 'Really?')) ?>

  • (string) options_for_javascript ($options) Browse code

    $options

    converts the the PHP options array into a javscript array

    returns javascript arry equivalent