Exemplo n.º 1
0
 public function configure()
 {
     $nameWidget = new sfWidgetFormInputText(array());
     $nameWidget->setDefault(sfContext::getInstance()->getUser());
     $emailWidget = new sfWidgetFormInputText(array());
     $emailWidget->setDefault(sfContext::getInstance()->getUser()->getGuardUser()->getUsername());
     $this->setWidgets(array('name' => $nameWidget, 'email' => $emailWidget, 'callback_uri' => new sfWidgetFormInputText(array()), 'application_uri' => new sfWidgetFormInputText(array()), 'application_title' => new sfWidgetFormInputText(array()), 'application_descr' => new sfWidgetFormTextarea(array()), 'application_notes' => new sfWidgetFormTextarea(array()), 'application_type' => new sfWidgetFormSelect(array('choices' => self::$tipos)), 'application_commercial' => new sfWidgetFormInputCheckbox(array())));
     $this->widgetSchema->setNameFormat('profile[%s]');
     $this->setValidators(array('name' => new sfValidatorString(array('required' => true)), 'email' => new sfValidatorEmail(array('required' => true)), 'callback_uri' => new sfValidatorString(array('required' => false)), 'application_uri' => new sfValidatorUrl(array('required' => false)), 'application_title' => new sfValidatorString(array('required' => false)), 'application_descr' => new sfValidatorString(array('required' => false)), 'application_notes' => new sfValidatorString(array('required' => false)), 'application_type' => new sfValidatorString(array('required' => false)), 'application_commercial' => new sfValidatorString(array('required' => false))));
     $this->widgetSchema->setNameFormat('application[%s]');
 }
 /**
  * @param  string $name        The element name
  * @param  string $value       The date displayed in this widget
  * @param  array  $attributes  An array of HTML attributes to be merged with the default HTML attributes
  * @param  array  $errors      An array of errors for the field
  *
  * @return string An HTML tag string
  *
  * @see sfWidgetForm
  */
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     $url = url_for('@pm_widget_form_propel_input_by_code', true);
     $options_without_template = $this->getOptions();
     unset($options_without_template['template']);
     return parent::render($name, $value, $attributes, $errors) . sprintf($this->getOption('template'), $this->generateId($name . '_result'), $this->generateId($name), $url, serialize($options_without_template));
 }
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     if (is_array($value)) {
         $values = array($value['postcode'], $value['city'], $value['address']);
     } elseif ($value) {
         $values = explode('|', $value);
     } elseif (!$value) {
         $values = array('', '', '');
     }
     $sfWidget = new sfWidgetFormInputText();
     $postcode = $sfWidget->render($name . '[postcode]', $values[0], array('maxlength' => 5, 'style' => 'width:50px'));
     $city = $sfWidget->render($name . '[city]', $values[1], array('style' => 'width:100px'));
     $address = $sfWidget->render($name . '[address]', $values[2], array('style' => 'width:200px'));
     $res = str_replace(array('%postcode%', '%city%', '%address%'), array($postcode, $city, $address), $this->getOption('iformat'));
     return $res;
     // parent::render($name, $value, $attributes, $errors);
 }
 /**
  * Configures the current widget.
  *
  * Available options:
  *
  * @param string fields                Fields to feed with the response
  * 
  * @see sfWidgetForm
  */
 protected function configure($options = array(), $attributes = array())
 {
     $this->addOption('fields', sfConfig::get('app_br_cep_form_fields'));
     // Tamanho máximo do CEP, com hífen
     parent::configure($options, $attributes);
     $this->setAttribute('maxlength', '9');
     $this->setOption('type', 'text');
 }
 /**
  * 
  */
 public function configure($options = array(), $attributes = array())
 {
     parent::configure($options, $attributes);
     $this->setAttribute('size', 60);
     $this->setAttribute('maxlength', 255);
     $this->setAttribute('class', 'tag-input');
     $this->setAttribute('autocomplete', 'off');
 }
 /**
  * Render field
  * 
  * @param   string  $name       Element name
  * @param   string  $value      Field value [optional]
  * @param   array   $attributes HTML attributes [optional]
  * @param   array   $errors     Field errors [optional]
  * @return  string  XHTML compliant tag
  */
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     if (!is_array($value)) {
         $value = (string) $value == (string) (int) $value ? (int) $value : strtotime($value);
         if (false === $value) {
             $value = '';
         } else {
             $value = array('year' => date('Y', $value), 'month' => date('m', $value), 'day' => date('d', $value));
         }
     }
     $dateValue = '';
     if (is_array($value)) {
         $value = array_merge(array('year' => null, 'month' => null, 'day' => null), $value);
         $dateValue = strtr($this->getOption('format'), array('%month%' => $value['month'], '%year%' => $value['year'], '%day%' => $value['day']));
     }
     $widget = new sfWidgetFormInputText(array(), $attributes);
     return $widget->render($name, $dateValue) . '<script type="text/javascript">if(typeof jQuery!=\'undefined\'){$(function(){$("#' . $widget->generateId($name, $dateValue) . '").datepicker(' . ($this->getOption('config') ? '{' . $this->getOption('config') . '}' : '') . ');});' . ($this->getOption('lang') ? '$("#' . $widget->generateId($name, $dateValue) . '").datepicker($.datepicker.regional[\'' . $this->getOption('lang') . '\']);' : '') . '}</script>';
 }
 /**
  * @param  string $name        The element name
  * @param  string $value       The value displayed in this widget
  * @param  array  $attributes  An array of HTML attributes to be merged with the default HTML attributes
  * @param  array  $errors      An array of errors for the field
  *
  * @return string An HTML tag string
  *
  * @see sfWidgetForm
  */
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     if (is_array($attributes['data-options'])) {
         $attributes['data-options'] = json_encode($attributes['data-options']);
     }
     $response = sfContext::getInstance()->getResponse();
     $response->addStylesheet('/jfPortableDeviceExtFormsPlugin/datebox/jquery.mobile.datebox.css', 'last');
     $response->addJavascript('/jfPortableDeviceExtFormsPlugin/datebox/jquery.mobile.datebox.min.js', 'last');
     return parent::render($name, $value, $attributes, $errors);
 }
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     $colorAttributes = array('style' => 'background-color:' . $value, 'id' => 'preview_' . $name, 'class' => 'color');
     $result = $this->renderContentTag('dd', parent::render($name, $value, $attributes, $errors));
     $i18n = sfContext::getInstance()->getI18N();
     if ($this->getOption('is_display_pre_color')) {
         $result .= $this->renderContentTag('dd', $this->renderContentTag('div', $i18n->__($this->getOption('pre_color_label'))), array_merge($colorAttributes, array('id' => 'preview_pre_' . $name)));
     }
     $result .= $this->renderContentTag('dd', $this->renderContentTag('div', $i18n->__($this->getOption('color_label'))), $colorAttributes);
     return $result;
 }
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     $select_parent = parent::render($name, $value, $attributes, $errors);
     //$foreing_id = $this->getOption('foreing_id') ? $this->getOption('foreing_id') : strtolower($this->getOption('model').'_id');
     $option_name = $this->getOption('option_name') ? $this->getOption('option_name') : 'widget-time';
     //$where = $this->getOption('where') ? ' where="'.$this->getOption('where').'"' : '';
     $conten_tag = '<div>';
     $conten_tag .= $select_parent;
     $conten_tag .= '<input type=#text" class="input_text" name="' . $option_name . '" />';
     $conten_tag .= '</div>';
     return $conten_tag;
 }
Exemplo n.º 10
0
 /**
  * Renders the widget.
  *
  * @param  string $name        The element name
  * @param  string $value       The value displayed in this widget
  * @param  array  $attributes  An array of HTML attributes to be merged with the default HTML attributes
  * @param  array  $errors      An array of errors for the field
  *
  * @return string An HTML tag string
  *
  * @see sfWidgetForm
  */
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     $widget = parent::render($name, $value, $attributes, $errors);
     $class = '';
     if ($this->getOption('prepend_text')) {
         $widget = sprintf('<span class="add-on">%s</span>%s', $this->getOption('prepend_text'), $widget);
         $class .= 'input-prepend';
     }
     if ($this->getOption('append_text')) {
         $widget = sprintf('%s<span class="add-on">%s</span>', $widget, $this->getOption('append_text'));
         $class .= ' input-append';
     }
     if ($class) {
         $widget = sprintf('<div class="text-%s %s">%s</div>', $this->generateId($name), trim($class), $widget);
     }
     return $widget;
 }
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     $values = array_merge(array('text' => '', 'is_empty' => false), is_array($value) ? $value : array());
     $divname = $this->getOption('divname');
     $obj_name = $this->getName($value);
     $obj_id = $this->generateId($name) . "_name";
     $input = parent::render($name, $value, $attributes, $errors);
     $attributes = array_merge($attributes, array('id' => $obj_id, 'class' => 'large_size'));
     $input .= parent::render('', $obj_name, $attributes, $errors);
     if ($this->getOption('nullable')) {
         $options = array('src' => '/images/remove.png', 'class' => $divname . '_reference_clear');
         if ($obj_name == '') {
             $options['class'] .= ' hidden';
         }
         $input .= $this->renderTag('img', $options);
     }
     $script_header = '<script type="text/javascript"> $(document).ready(function () {';
     $script_footer = '});</script>';
     $script_formated = sprintf('jQuery("#%1$s").focus(function() 
                                 {
                                   if (jQuery("div.%2$ssearch_box:hidden").length)
                                   {
                                     jQuery("div.%2$ssearch_box, ul.tab_choice").slideDown();
                                   }
                                   jQuery("div.%2$ssearch_box table#search_and_choose tbody td:first input:first").focus();
                                 });
                                 
                                 $(".%2$sreference_clear").click(function()
                                 {
                                   $(this).prevAll("input").val("");
                                   $(this).hide();
                                 });
                                ', $obj_id, $divname);
     foreach ($this->getOption('fieldsHidders') as $key => $value) {
         $script_formated .= sprintf('jQuery("#%1$s").focus(function() 
                                    {
                                      if (jQuery("div.%2$ssearch_box:visible").length)
                                      {
                                        jQuery("div.%2$ssearch_box, ul.tab_choice").slideUp();
                                      }
                                    });
                                   ', $value, $divname);
     }
     return $input . $script_header . $script_formated . $script_footer;
 }
    /**
     * Renders the widget.
     *
     * @param  string $name        The element name
     * @param  string $value       The value displayed in this widget
     * @param  array  $attributes  An array of HTML attributes to be merged with the default HTML attributes
     * @param  array  $errors      An array of errors for the field
     *
     * @return string An HTML tag string
     * @see sfWidgetForm
     */
    public function render($name, $value = null, $attributes = array(), $errors = array())
    {
        if (!$this->getAttribute('size')) {
            $this->setAttribute('size', $this->getOption('with_time') ? 15 : 9);
        }
        $this->default_picker_options['timeFormat'] = $this->getOption('time_format');
        $this->default_picker_options['dateFormat'] = $this->getOption('date_format');
        $this->default_picker_options['showSecond'] = strstr($this->getOption('time_format'), 'ss') !== false;
        if ($timestamp = strtotime($value)) {
            $value = strtr($this->getOption('date_format'), array('yy' => date('Y', $timestamp), 'mm' => date('m', $timestamp), 'dd' => date('d', $timestamp), 'y' => date('y', $timestamp), 'm' => date('n', $timestamp), 'd' => date('j', $timestamp)));
            if ($this->getOption('with_time')) {
                $value .= ' ' . strtr($this->getOption('time_format'), array('hh' => date('H', $timestamp), 'mm' => date('i', $timestamp), 'ss' => date('s', $timestamp), 'h' => date('G', $timestamp), 'm' => intval(date('i', $timestamp)), 's' => intval(date('s', $timestamp))));
            }
        }
        // Generate the datePicker javascript code
        $jq_picker_options = array_merge($this->default_picker_options, $this->getOption('jq_picker_options'));
        if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
            $jq_picker_options = json_encode($jq_picker_options, JSON_FORCE_OBJECT);
        } else {
            $jq_picker_options = json_encode($jq_picker_options);
        }
        $jq_picker_options = str_replace('\\/', '/', $jq_picker_options);
        // Fix for: http://bugs.php.net/bug.php?id=49366
        $pickerClass = $this->getOption('with_time') ? 'datetimepicker' : 'datepicker';
        $id = $this->generateId($name);
        $attributes['class'] = 'sfDateTimePicker' . (isset($attributes['class']) ? ' ' . $attributes['class'] : '');
        $html = parent::render($name, $value, $attributes, $errors);
        foreach ($this->getStylesheets() as $file => $options) {
            $html .= stylesheet_tag($file, $options);
        }
        foreach ($this->getJavaScripts() as $file) {
            $html .= javascript_include_tag($file);
        }
        $html .= <<<EOHTML

<script type="text/javascript">
  jQueryPicker(function(){
    jQueryPicker("#{$id}").{$pickerClass}({$jq_picker_options});
//    jQueryPicker(".ui-datepicker").draggable();
  });
</script>

EOHTML;
        return $html;
    }
Exemplo n.º 13
0
$f->setValidator('name', $v3 = new sfValidatorPass());
$t->ok($f->getValidator('name') == $v3, '->setValidator() sets a validator for a field');
// ->setWidgets() ->setWidgetSchema() ->getWidgetSchema() ->getWidget() ->setWidget()
$t->diag('->setWidgets() ->setWidgetSchema() ->getWidgetSchema()');
$f = new FormTest();
$widgets = array('first_name' => new sfWidgetFormInputText(), 'last_name' => new sfWidgetFormInputText());
$widgetSchema = new sfWidgetFormSchema($widgets);
$f->setWidgetSchema($widgetSchema);
$t->ok($f->getWidgetSchema() == $widgetSchema, '->setWidgetSchema() sets the current widget schema');
$f->setWidgets($widgets);
$schema = $f->getWidgetSchema();
$widgets['first_name']->setParent($schema);
$widgets['last_name']->setParent($schema);
$t->ok($schema['first_name'] == $widgets['first_name'], '->setWidgets() sets field widgets');
$t->ok($schema['last_name'] == $widgets['last_name'], '->setWidgets() sets field widgets');
$f->setWidget('name', $w3 = new sfWidgetFormInputText());
$w3->setParent($schema);
$t->ok($f->getWidget('name') == $w3, '->setWidget() sets a widget for a field');
// ArrayAccess interface
$t->diag('ArrayAccess interface');
$f = new FormTest();
$f->setWidgetSchema(new sfWidgetFormSchema(array('first_name' => new sfWidgetFormInputText(array('default' => 'Fabien')), 'last_name' => new sfWidgetFormInputText(), 'image' => new sfWidgetFormInputFile())));
$f->setValidatorSchema(new sfValidatorSchema(array('first_name' => new sfValidatorPass(), 'last_name' => new sfValidatorPass(), 'image' => new sfValidatorPass())));
$f->setDefaults(array('image' => 'default.gif'));
$f->embedForm('embedded', new sfForm());
$t->ok($f['first_name'] instanceof sfFormField, '"sfForm" implements the ArrayAccess interface');
$t->is($f['first_name']->render(), '<input type="text" name="first_name" value="Fabien" id="first_name" />', '"sfForm" implements the ArrayAccess interface');
try {
    $f['image'] = 'image';
    $t->fail('"sfForm" ArrayAccess implementation does not permit to set a form field');
} catch (LogicException $e) {
Exemplo n.º 14
0
<?php

/*
 * This file is part of the symfony package.
 * (c) Fabien Potencier <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
require_once dirname(__FILE__) . '/../../bootstrap/unit.php';
$t = new lime_test(94);
$w1 = new sfWidgetFormInputText(array(), array('class' => 'foo1'));
$w2 = new sfWidgetFormInputText();
// __construct()
$t->diag('__construct()');
$w = new sfWidgetFormSchema();
$t->is($w->getFields(), array(), '__construct() can take no argument');
$w = new sfWidgetFormSchema(array('w1' => $w1, 'w2' => $w2));
$w1->setParent($w);
$w2->setParent($w);
$t->ok($w->getFields() == array('w1' => $w1, 'w2' => $w2), '__construct() can take an array of named sfWidget objects');
try {
    $w = new sfWidgetFormSchema('string');
    $t->fail('__construct() throws a exception when passing a non supported first argument');
} catch (InvalidArgumentException $e) {
    $t->pass('__construct() throws an exception when passing a non supported first argument');
}
$t->is($w->getFormFormatterName(), 'table', '__construct() sets "form_formatter" option to "table" by default');
$w = new sfWidgetFormSchema(array(), array('form_formatter' => 'list'));
$t->is($w->getFormFormatterName(), 'list', '__construct() can override the default value for the "form_formatter" option');
$t->is($w->getNameFormat(), '%s', '__construct() sets "name_format" option to "table" by default');
 /**
  * Renders the input field for widget.
  *
  * @param  string $name        The element name
  * @param  string $value       The this widget is checked if value is not null
  * @param  array  $attributes  An array of HTML attributes to be merged with the default HTML attributes
  * @param  array  $errors      An array of errors for the field
  *
  * @return string An HTML tag string
  *
  * @see sfWidgetFormInputText
  */
 public function renderInputField($name, $value = null, $attributes = array(), $errors = array())
 {
     return parent::render($name, $value, $attributes, $errors);
 }
Exemplo n.º 16
0
 public function configure($options = array(), $attributes = array())
 {
     parent::configure($options, $attributes);
 }
Exemplo n.º 17
0
<?php

/*
 * This file is part of the symfony package.
 * (c) Fabien Potencier <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
require_once dirname(__FILE__) . '/../../bootstrap/unit.php';
$t = new lime_test(31);
// widgets
$authorSchema = new sfWidgetFormSchema(array('id' => new sfWidgetFormInputHidden(), 'name' => $nameWidget = new sfWidgetFormInputText()));
$authorSchema->setNameFormat('article[author][%s]');
$schema = new sfWidgetFormSchema(array('title' => $titleWidget = new sfWidgetFormInputText(), 'author' => $authorSchema));
$schema->setNameFormat('article[%s]');
$titleWidget->setParent($schema);
// errors
$authorErrorSchema = new sfValidatorErrorSchema(new sfValidatorString());
$authorErrorSchema->addError(new sfValidatorError(new sfValidatorString(), 'name error'), 'name');
$articleErrorSchema = new sfValidatorErrorSchema(new sfValidatorString());
$articleErrorSchema->addError($titleError = new sfValidatorError(new sfValidatorString(), 'title error'), 'title');
$articleErrorSchema->addError($authorErrorSchema, 'author');
$parent = new sfFormFieldSchema($schema, null, 'article', array('title' => 'symfony', 'author' => array('name' => 'Fabien')), $articleErrorSchema);
$f = $parent['title'];
$child = $parent['author'];
// ->getValue() ->getWidget() ->getParent() ->getError() ->hasError()
$t->diag('->getValue() ->getName() ->getWidget() ->getParent() ->getError() ->hasError()');
$t->ok($f->getWidget() == $titleWidget, '->getWidget() returns the form field widget');
$t->is($f->getName(), 'title', '->getName() returns the form field name');
$t->is($f->getValue(), 'symfony', '->getValue() returns the form field value');
 public function render($name, $value = ' ', $attributes = array(), $errors = array())
 {
     $input = parent::render($name, abs($value), $attributes);
     return $input;
 }
 /**
  * Renders the widget.
  *
  * @param  string $name        The element name
  * @param  string $value       The value selected in this widget
  * @param  array  $attributes  An array of HTML attributes to be merged with the default HTML attributes
  * @param  array  $errors      An array of errors for the field
  *
  * @return string An HTML tag string
  *
  * @see sfWidgetForm
  */
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     if (is_null($value)) {
         $value = array();
     }
     $choices = $this->getOption('choices');
     if ($choices instanceof sfCallable) {
         $choices = $choices->call();
     }
     $associated = array();
     $unassociated = array();
     if (!is_array($value)) {
         $value = array($value);
     }
     foreach ($choices as $key => $option) {
         if (in_array(strval($key), $value)) {
             $associated[$key] = $option;
         } else {
             $unassociated[$key] = $option;
         }
     }
     $size = isset($attributes['size']) ? $attributes['size'] : (isset($this->attributes['size']) ? $this->attributes['size'] : 10);
     $id = $this->generateId($name);
     $error_id = 'error_' . $id;
     // The two select boxes
     $associatedWidget = new sfWidgetFormSelect(array('multiple' => true, 'choices' => $associated), array('size' => $size, 'class' => $this->getOption('class_select') . '-selected'));
     $unassociatedWidget = new sfWidgetFormSelect(array('multiple' => true, 'choices' => $unassociated), array('size' => $size, 'class' => $this->getOption('class_select')));
     // The input box used to filter content of unassociated select box
     $filterWidget = new sfWidgetFormInputText(array(), array('class' => $this->getOption('filter_class')));
     // Options to be passed to the renderTag of reset filter image
     $filterResetOptions = array('src' => '/images/remove.png', 'id' => 'filter_' . $id . "_clear", 'class' => 'filter_clear', 'alt' => __('Reset filter'), 'title' => __('Reset filter'));
     $addOptionHTML = '';
     // If add of a value in distant table is possible and activated
     if ($this->getOption('add_active')) {
         // Define the add value input box
         $addOptionWidget = new sfWidgetFormInputText(array(), array('id' => 'add_' . $id, 'class' => $this->getOption('add_class')));
         $addOptionWidget->setLabel(__('Add new value:'));
         // Options to be passed to the renderTag of add option image
         $addImageOptions = array('src' => '/images/add_green.png', 'id' => 'add_' . $id . '_image', 'class' => 'add_option', 'alt' => __('Add value'), 'title' => __('Add value'));
         // Options to be passed to the timer displayed while tryin' to insert a value
         $addTimerImageOptions = array('src' => '/images/loader.gif', 'id' => 'add_' . $id . '_loader', 'style' => 'display:none;');
         $addLinkOptions = array('id' => 'add_' . $id . '_link', 'class' => 'add_option', 'href' => url_for($this->getOption('add_url')));
         $addOptionHTML = $this->renderContentTag('label', $addOptionWidget->getLabel(), array('for' => 'add_' . $id)) . $addOptionWidget->render('add_' . $name) . $this->renderContentTag('a', $this->renderTag('img', $addImageOptions), $addLinkOptions) . $this->renderTag('img', $addTimerImageOptions);
     }
     return strtr($this->getOption('template'), array('%class%' => $this->getOption('class'), '%class_select%' => $this->getOption('class_select'), '%id%' => $id, '%label_associated%' => $this->getOption('label_associated'), '%label_unassociated%' => $this->getOption('label_unassociated'), '%associate%' => sprintf('<a href="#" id="associate_' . $id . '">%s</a>', $this->getOption('associate')), '%unassociate%' => sprintf('<a href="#" id="unassociate_' . $id . '">%s</a>', $this->getOption('unassociate')), '%associated%' => $associatedWidget->render($name), '%unassociated%' => $unassociatedWidget->render('unassociated_' . $name), '%filter%' => $filterWidget->render('filter_' . $name), '%filter_reset%' => $this->renderTag('img', $filterResetOptions), '%add_option%' => $addOptionHTML, '%error_id%' => $error_id));
 }
Exemplo n.º 20
0
<?php

/*
 * This file is part of the symfony package.
 * (c) Fabien Potencier <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
require_once __DIR__ . '/../../bootstrap/unit.php';
$t = new lime_test(5);
$w = new sfWidgetFormInputText();
// ->render()
$t->diag('->render()');
$t->is($w->render('foo'), '<input type="text" name="foo" id="foo" />', '->render() renders the widget as HTML');
$t->is($w->render('foo', 'bar'), '<input type="text" name="foo" value="bar" id="foo" />', '->render() can take a value for the input');
$t->is($w->render('foo', '', array('type' => 'password', 'class' => 'foobar')), '<input type="password" name="foo" value="" class="foobar" id="foo" />', '->render() can take HTML attributes as its third argument');
$w = new sfWidgetFormInputText(array(), array('class' => 'foobar'));
$t->is($w->render('foo'), '<input class="foobar" type="text" name="foo" id="foo" />', '__construct() can take default HTML attributes');
$t->is($w->render('foo', null, array('class' => 'barfoo')), '<input class="barfoo" type="text" name="foo" id="foo" />', '->render() can override default attributes');
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     $res = parent::render($name, $value, $attributes, $errors);
     $res .= ' ' . __('Commentaire') . ' (<em>' . __('facultatif') . '</em>) : <input type="text" name="' . str_replace('date', 'comment', $name) . '" value="' . $this->comment_value . '" />';
     return $res;
 }
 /**
  * @see sfWidgetFormInputText
  */
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     $tag = parent::renderTag('input', array_merge(array('type' => $this->getOption('type'), 'name' => $name, 'value' => $value), $attributes));
     $javascript = sprintf("\n<script type=\"text/javascript\">\n  \$(document).ready(function(){\n    \$('#%s').timePicker({\n      show24Hours: false,\n      step: 30,\n      startTime: '05:00',\n      endTime:   '23:00'\n    });\n  });\n</script>", $this->generateId($name, $value));
     return $tag . $javascript;
 }
 /**
  * Configures the current widget.
  *
  * @param array $options     An array of options
  * @param array $attributes  An array of default HTML attributes
  *
  * @see sfWidgetForm
  */
 protected function configure($options = array(), $attributes = array())
 {
     parent::configure($options, $attributes);
     $this->addRequiredOption('config');
     $this->setOption('is_hidden', empty($options['config']));
 }
 public function getStylesheets()
 {
     return array_merge(parent::getStylesheets(), array('lib.sfWidgetFormDmPageLink' => null));
 }
 /**
  * Configures the current widget.
  *
  * @param array $options     An array of options
  * @param array $attributes  An array of default HTML attributes
  *
  * @see sfWidgetForm
  */
 protected function configure($options = array(), $attributes = array())
 {
     parent::configure($options, $attributes);
     $this->setOption('type', 'float');
 }
<?php

/*
 * This file is part of the symfony package.
 * (c) Fabien Potencier <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
require_once __DIR__ . '/../../bootstrap/unit.php';
$t = new lime_test(16);
$w1 = new sfWidgetFormInputText();
$w2 = new sfWidgetFormInputText();
$ws = new sfWidgetFormSchema(array('w1' => $w1));
$w = new sfWidgetFormSchemaDecorator($ws, "<table>\n%content%</table>");
// ->getWidget()
$t->diag('->getWidget()');
$t->is($w->getWidget(), $ws, '->getWidget() returns the decorated widget');
// ->render()
$t->diag('->render()');
$output = <<<EOF
<table>
<tr>
  <th><label for="w1">W1</label></th>
  <td><input type="text" name="w1" id="w1" /></td>
</tr>
</table>
EOF;
$t->is($w->render(null), fix_linebreaks($output), '->render() decorates the widget');
// implements ArrayAccess
$t->diag('implements ArrayAccess');
Exemplo n.º 27
0
 protected function getNumberSettingWidget(DmSetting $setting)
 {
     $widget = new sfWidgetFormInputText(array(), $setting->getParamsArray());
     return $widget->setDefault($setting->get('value'));
 }
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     $value = $this->convertToLocaleNumber($value);
     return parent::render($name, $value, $attributes, $errors);
 }