I found my way but had to change the sfForm class.
If someone has a better way, not messing with the "core", please help.
I had to change the sfForm::offsetGet as below:
public function offsetGet($name)
{
if (!isset($this->formFields[$name]))
{
if (!$widget = $this->widgetSchema[$name])
{
throw new InvalidArgumentException(sprintf('Widget "%s" does
not exist.', $name));
}
$values = $this->isBound ? $this->taintedValues : $this->defaults;
$class = $widget instanceof sfWidgetFormSchema ?
'sfFormFieldSchema' : 'sfFormField';
$this->formFields[$name] = new $class($widget,
$this->getFormFieldSchema(), $name, isset($values[$name]) ?
$values[$name] : null, $this->errorSchema[$name]);
#############################################
#############################################
if($this->formFields[$name]->getWidget()->hasOption('doNotConvertValues'))
{
if($this->isBound()) {
$this->formFields[$name]->getWidget()->setOption('doNotConvertValues',true);
}
}
#############################################
#############################################
}
return $this->formFields[$name];
}
and then on my widget render function I did :
public function render($name, $value = null, $attributes = array(),
$errors = array())
{
######################################
######################################
if(!$this->getOption('doNotConvertValues')) {
$numberFormat = new sfNumberFormat($this->getOption('culture'));
$value = $numberFormat->format($value);
}
######################################
######################################
return $this->renderTag('input', array_merge(array('type' =>
$this->getOption('type'), 'name' => $name, 'value' => $value),
$attributes));
}
2008/10/13 Bruno Reis <[EMAIL PROTECTED]>:
> Hi there,
>
> I made the following class to render my decimal numbers with commas
> instead of dots. But if the form does not validate, then the render
> function is called with the user entered value. So the first time, for
> instance, its called with 14.54(dot) to show the form. It is shown as
> 14,54(comma). When the user submits the form (that is not validated) ,
> then its called with 14,54 (comma) and does not work as expected.
>
> Am I doing something wrong here?
> Is the Class right implemented?
>
> thks,
> Bruno
>
> -----
>
> class sfWidgetFormInputDecimal extends sfWidgetForm
> {
>
> protected function configure($options = array(), $attributes = array())
> {
> parent::configure($options,$attributes);
> $this->addRequiredOption('culture');
> }
>
>
> public function render($name, $value = null, $attributes = array(),
> $errors = array())
> {
> $numberFormat = new sfNumberFormat($this->getOption('culture'));
> $value = $numberFormat->format($value);
> return $this->renderTag('input', array_merge(array('type' =>
> $this->getOption('type'), 'name' => $name, 'value' => $value),
> $attributes));
> }
> }
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---