Re: [symfony-users] Re: No EntityToIDTransformer in PR6 ?

2011-02-21 Thread Dan Leech
also, if you have found yourself wondering why the default option isnt
selected in the choice field when you display your form, like I have
been for the past 4 hours

You need to typecast the return value of "transform" to a string :)

   return (string) current( $this->getOption('em')->getUnitOfWork()-
>getEntityIdentifier($entity) );

On 21 February 2011 11:32, Dan Leech  wrote:
> thanks :)
>
> On 20 February 2011 13:33, Reuven  wrote:
>> I reimplemented one and it works.
>> Here the code.
>>
>> namespace Symfony\Component\Form\ValueTransformer;
>> use Symfony\Component\Form\Configurable;
>> class EntityToIDTransformer extends Configurable implements
>> ValueTransformerInterface
>> {
>>    protected function configure()
>>    {
>>        $this->addRequiredOption('em');
>>        $this->addRequiredOption('class');
>>
>>        parent::configure();
>>    }
>>
>>    public function reverseTransform($newId)
>>    {
>>        if (empty($newId)) {
>>            return null;
>>        }
>>
>>        return $this->getOption('em')->find($this->getOption('class'),
>> $newId);
>>    }
>>
>>    public function transform($entity)
>>    {
>>        if (empty($entity)) {
>>            return 0;
>>        }
>>
>>        return current( $this->getOption('em')->getUnitOfWork()-
>>>getEntityIdentifier($entity) );
>>    }
>> }
>>
>> I hope it will help you.
>>
>> Regards,
>> Reuven
>>
>> On 20 fév, 12:33, Dan Leech  wrote:
>>> hello
>>>
>>> I am trying to reimplement the old Doctrine transformers after
>>> upgrading from PR5, but there seems to be a contradiction with the
>>> interface, reverseTransform is called with 2 arguments.
>>>
>>>     // Symfony\Component\Form\Field
>>>     protected function reverseTransform($value)
>>>     {
>>>             return '' === $value ? null : $value;
>>>         }
>>>         return $this->valueTransformer->reverseTransform($value, 
>>> $this->data);
>>>     }
>>>
>>> but the interface only allows one:
>>>
>>>     // Symfony\Component\Form\ValueTransformer\ValueTransformerInterface
>>>     function reverseTransform($value);
>>>
>>> If the interface is correct, how can the transformers access the form
>>> data object?
>>>
>>> thanks
>>>
>>> dan
>>>
>>> On 18 February 2011 13:24, Bernhard Schussek  wrote:
>>>
>>>
>>>
>>> > It was removed because its implementation was buggy/bad. You can copy
>>> > the old implementation into your project and use it this way. A new
>>> > version of it will come soon.
>>>
>>> > Bernhard
>>>
>>> > --
>>> > If you want to report a vulnerability issue on symfony, please send it to 
>>> > security at symfony-project.com
>>>
>>> > You received this message because you are subscribed to the Google
>>> > Groups "symfony users" group.
>>> > To post to this group, send email to symfony-users@googlegroups.com
>>> > To unsubscribe from this group, send email to
>>> > symfony-users+unsubscr...@googlegroups.com
>>> > For more options, visit this group at
>>> >http://groups.google.com/group/symfony-users?hl=en
>>>
>>> --
>>> Dan Leech
>>>
>>> Web Developerwww.dantleech.com
>>
>> --
>> If you want to report a vulnerability issue on symfony, please send it to 
>> security at symfony-project.com
>>
>> You received this message because you are subscribed to the Google
>> Groups "symfony users" group.
>> To post to this group, send email to symfony-users@googlegroups.com
>> To unsubscribe from this group, send email to
>> symfony-users+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/symfony-users?hl=en
>>
>
>
>
> --
> Dan Leech
>
> Web Developer
> www.dantleech.com
>



-- 
Dan Leech

Web Developer
www.dantleech.com

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


Re: [symfony-users] Re: No EntityToIDTransformer in PR6 ?

2011-02-21 Thread Dan Leech
thanks :)

On 20 February 2011 13:33, Reuven  wrote:
> I reimplemented one and it works.
> Here the code.
>
> namespace Symfony\Component\Form\ValueTransformer;
> use Symfony\Component\Form\Configurable;
> class EntityToIDTransformer extends Configurable implements
> ValueTransformerInterface
> {
>    protected function configure()
>    {
>        $this->addRequiredOption('em');
>        $this->addRequiredOption('class');
>
>        parent::configure();
>    }
>
>    public function reverseTransform($newId)
>    {
>        if (empty($newId)) {
>            return null;
>        }
>
>        return $this->getOption('em')->find($this->getOption('class'),
> $newId);
>    }
>
>    public function transform($entity)
>    {
>        if (empty($entity)) {
>            return 0;
>        }
>
>        return current( $this->getOption('em')->getUnitOfWork()-
>>getEntityIdentifier($entity) );
>    }
> }
>
> I hope it will help you.
>
> Regards,
> Reuven
>
> On 20 fév, 12:33, Dan Leech  wrote:
>> hello
>>
>> I am trying to reimplement the old Doctrine transformers after
>> upgrading from PR5, but there seems to be a contradiction with the
>> interface, reverseTransform is called with 2 arguments.
>>
>>     // Symfony\Component\Form\Field
>>     protected function reverseTransform($value)
>>     {
>>             return '' === $value ? null : $value;
>>         }
>>         return $this->valueTransformer->reverseTransform($value, 
>> $this->data);
>>     }
>>
>> but the interface only allows one:
>>
>>     // Symfony\Component\Form\ValueTransformer\ValueTransformerInterface
>>     function reverseTransform($value);
>>
>> If the interface is correct, how can the transformers access the form
>> data object?
>>
>> thanks
>>
>> dan
>>
>> On 18 February 2011 13:24, Bernhard Schussek  wrote:
>>
>>
>>
>> > It was removed because its implementation was buggy/bad. You can copy
>> > the old implementation into your project and use it this way. A new
>> > version of it will come soon.
>>
>> > Bernhard
>>
>> > --
>> > If you want to report a vulnerability issue on symfony, please send it to 
>> > security at symfony-project.com
>>
>> > You received this message because you are subscribed to the Google
>> > Groups "symfony users" group.
>> > To post to this group, send email to symfony-users@googlegroups.com
>> > To unsubscribe from this group, send email to
>> > symfony-users+unsubscr...@googlegroups.com
>> > For more options, visit this group at
>> >http://groups.google.com/group/symfony-users?hl=en
>>
>> --
>> Dan Leech
>>
>> Web Developerwww.dantleech.com
>
> --
> If you want to report a vulnerability issue on symfony, please send it to 
> security at symfony-project.com
>
> You received this message because you are subscribed to the Google
> Groups "symfony users" group.
> To post to this group, send email to symfony-users@googlegroups.com
> To unsubscribe from this group, send email to
> symfony-users+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/symfony-users?hl=en
>



-- 
Dan Leech

Web Developer
www.dantleech.com

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


Re: [symfony-users] No EntityToIDTransformer in PR6 ?

2011-02-20 Thread Dan Leech
hello

I am trying to reimplement the old Doctrine transformers after
upgrading from PR5, but there seems to be a contradiction with the
interface, reverseTransform is called with 2 arguments.

// Symfony\Component\Form\Field
protected function reverseTransform($value)
{
return '' === $value ? null : $value;
}
return $this->valueTransformer->reverseTransform($value, $this->data);
}

but the interface only allows one:

// Symfony\Component\Form\ValueTransformer\ValueTransformerInterface
function reverseTransform($value);

If the interface is correct, how can the transformers access the form
data object?

thanks

dan

On 18 February 2011 13:24, Bernhard Schussek  wrote:
> It was removed because its implementation was buggy/bad. You can copy
> the old implementation into your project and use it this way. A new
> version of it will come soon.
>
> Bernhard
>
> --
> If you want to report a vulnerability issue on symfony, please send it to 
> security at symfony-project.com
>
> You received this message because you are subscribed to the Google
> Groups "symfony users" group.
> To post to this group, send email to symfony-users@googlegroups.com
> To unsubscribe from this group, send email to
> symfony-users+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/symfony-users?hl=en
>



-- 
Dan Leech

Web Developer
www.dantleech.com

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Custom routing config handler broken ...

2010-07-13 Thread Dan Leech
x27;1',
  'logging' => '1',
  'generate_shortest_url' => true,
  'extra_parameters_as_query_string' => true,
));
$this -> routes["4"] -> compile();
$this -> routes["5"] = new sfRoute("/issues",array (
  'module' => 'gwProjectIssue',
  'action' => 'list',
));
$this -> routes["5"] -> setDefaultOptions(array (
  'load_configuration' => true,
  'suffix' => '',
  'default_module' => 'default',
  'default_action' => 'index',
  'debug' => '1',
  'logging' => '1',
  'generate_shortest_url' => true,
  'extra_parameters_as_query_string' => true,
));
$this -> routes["5"] -> compile();
$this -> routes["6"] = new sfRoute("/issue/:issue_number",array (
  'module' => 'gwProjectIssue',
  'action' => 'view',
));
$this -> routes["6"] -> setDefaultOptions(array (
  'load_configuration' => true,
  'suffix' => '',
  'default_module' => 'default',
  'default_action' => 'index',
  'debug' => '1',
  'logging' => '1',
  'generate_shortest_url' => true,
  'extra_parameters_as_query_string' => true,
));
$this -> routes["6"] -> compile();
$this -> routes["7"] = new sfRoute("/issue/task/create",array (
  'module' => 'gwProjectIssue',
  'action' => 'createTask',
));
$this -> routes["7"] -> setDefaultOptions(array (
  'load_configuration' => true,
  'suffix' => '',
  'default_module' => 'default',
  'default_action' => 'index',
  'debug' => '1',
  'logging' => '1',
  'generate_shortest_url' => true,
  'extra_parameters_as_query_string' => true,
));
$this -> routes["7"] -> compile();
$this -> routes["8"] = new sfRoute("/reports",array (
  'module' => 'gwProjectReport',
  'action' => 'index',
));
$this -> routes["8"] -> setDefaultOptions(array (
  'load_configuration' => true,
  'suffix' => '',
  'default_module' => 'default',
  'default_action' => 'index',
  'debug' => '1',
  'logging' => '1',
  'generate_shortest_url' => true,
  'extra_parameters_as_query_string' => true,
));
$this -> routes["8"] -> compile();
$this -> routes["13"] = new sfRoute("/search",array (
  'module' => 'gwProjectSearch',
  'action' => 'search',
));
$this -> routes["13"] -> setDefaultOptions(array (
  'load_configuration' => true,
  'suffix' => '',
  'default_module' => 'default',
  'default_action' => 'index',
  'debug' => '1',
  'logging' => '1',
  'generate_shortest_url' => true,
  'extra_parameters_as_query_string' => true,
));
$this -> routes["13"] -> compile();
$this -> routes["14"] = new sfRoute("/login",array (
  'module' => 'sfGuardAuth',
  'action' => 'signin',
));
$this -> routes["14"] -> setDefaultOptions(array (
  'load_configuration' => true,
  'suffix' => '',
  'default_module' => 'default',
  'default_action' => 'index',
  'debug' => '1',
  'logging' => '1',
  'generate_shortest_url' => true,
  'extra_parameters_as_query_string' => true,
));
$this -> routes["14"] -> compile();
$this -> routes["15"] = new sfRoute("/logout",array (
  'module' => 'sfGuardAuth',
  'action' => 'signout',
));
$this -> routes["15"] -> setDefaultOptions(array (
  'load_configuration' => true,
  'suffix' => '',
  'default_module' => 'default',
  'default_action' => 'index',
  'debug' => '1',
  'logging' => '1',
  'generate_shortest_url' => true,
  'extra_parameters_as_query_string' => true,
));
$this -> routes["15"] -> compile();
$this -> routes["21"] = new sfRoute("entity/:id",array (
  'module' => 'gwProjectEntity',
  'action' => 'view',
));
$this -> routes["21"] -> setDefaultOptions(array (
  'load_configuration' => true,
  'suffix' => '',
  'default_module' => 'default',
  'default_action' => 'index',
  'debug' => '1',
  'logging' => '1',
  'generate_shortest_url' => true,
  'extra_parameters_as_query_string' => true,
));
$this -> routes["21"] -> compile();

-- 
Dan Leech

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] sfGuardUserProfile in admin backend

2009-12-08 Thread Dan Leech
hi, i know there have been a couple of posts on this, and that it is
possible to embed the User Profile form in the sfGuardAdminForm .. but
.. should it work by default anyway?

I created a sfGuardProfile class, and then made some fields required.
The user could then edit their own profiles; then as an admin, if I
edit a users sfGuardUser record in the backend it wouldnt let me
submit the form, as it was invalid - it didnt have the required fields
from the profile class.

I looked into this and it was because the sfGuardAdminUserForm merges
the profile form:

$this->mergeForm($profileForm);

but doesnt render the form fields .. should it do this?

im using symfony 1.2

cheers

dan
-- 
Dan Leech

Dynamic Web Sites
www.dantleech.com

Bath Gigs
www.bathgigs.co.uk

--

You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-us...@googlegroups.com.
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en.




[symfony-users] Re: Exceptions in production environment

2008-12-19 Thread Dan Leech

yeah, its a symfony 1.2 project, upgraded from 1.0

the config_handlers.yml.php tries to instantiate a custom config
handler we use. When I include this config_handler manually in
ProjectConfiguration.class.php things work as expected.

2008/12/19 Lee Bolding :
>
> Autoloading again?
>
> Is this symfony 1.2?
>
>
>
>
>
> On 18 Dec 2008, at 17:11, Lee Bolding  wrote:
>
>>
>> it should be...
>>
>>> getApplicationConfiguration('ourapp', 'prod', false);
>>
>> The last arg is to enable/disable debugging
>>
>> On 18 Dec 2008, at 17:03, Dan Leech wrote:
>>
>>>
>>> Hi all
>>>
>>> We are receiving full stack traces in the production environment
>>> instead of the error500 template since upgrading to 1.2 from 1.0
>>>
>>> the font controller says : ... getApplicationConfiguration('ourapp',
>>> 'prod', true);
>>>
>>> Any ideas on why this might be?
>>>
>>> cheers
>>>
>>> dan
>>>
>>> --
>>> Dan Leech
>>>
>>> Dynamic Web Sites
>>> www.dantleech.com
>>>
>>> Bath Gigs
>>> www.bathgigs.co.uk
>>>
>>>>
>>
>>
>> >
>
> >
>



-- 
Dan Leech

Dynamic Web Sites
www.dantleech.com

Bath Gigs
www.bathgigs.co.uk

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---



[symfony-users] Re: Exceptions in production environment

2008-12-18 Thread Dan Leech

Thanks -- actually I remember that now

The reason it was set to true in the first place was that when it is
false the autoloading doesnt seem to work -- e.g. it cannot find
'sfYamlConfigHandler'

2008/12/18 Lee Bolding :
>
> it should be...
>
>> getApplicationConfiguration('ourapp', 'prod', false);
>
> The last arg is to enable/disable debugging
>
> On 18 Dec 2008, at 17:03, Dan Leech wrote:
>
>>
>> Hi all
>>
>> We are receiving full stack traces in the production environment
>> instead of the error500 template since upgrading to 1.2 from 1.0
>>
>> the font controller says : ... getApplicationConfiguration('ourapp',
>> 'prod', true);
>>
>> Any ideas on why this might be?
>>
>> cheers
>>
>> dan
>>
>> --
>> Dan Leech
>>
>> Dynamic Web Sites
>> www.dantleech.com
>>
>> Bath Gigs
>> www.bathgigs.co.uk
>>
>> >
>
>
> >
>



-- 
Dan Leech

Dynamic Web Sites
www.dantleech.com

Bath Gigs
www.bathgigs.co.uk

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---



[symfony-users] Exceptions in production environment

2008-12-18 Thread Dan Leech

Hi all

We are receiving full stack traces in the production environment
instead of the error500 template since upgrading to 1.2 from 1.0

the font controller says : ... getApplicationConfiguration('ourapp',
'prod', true);

Any ideas on why this might be?

cheers

dan

-- 
Dan Leech

Dynamic Web Sites
www.dantleech.com

Bath Gigs
www.bathgigs.co.uk

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---



[symfony-users] registering config handlers as runtime

2008-11-27 Thread Dan Leech

hi

is it possible to register config handlers at runtime, e.g. i would
like a plugin to register a config handler from its config.php

I was just about to write a task that aggregates config_handler.yml
files that are found in plugin/*/config into
config/config_handlers.yml -- but is there a better way?

cheers

dan

-- 
Dan Leech

Dynamic Web Sites
www.dantleech.com

Bath Gigs
www.bathgigs.co.uk

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
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
-~--~~~~--~~--~--~---



[symfony-users] Registering config handlers

2008-11-26 Thread Dan Leech

Hi all,

Is it possible for a plugin to register its own config handler rather
than having to manually add it to config_handlers.yml?

cheers

dan

-- 
Dan Leech

Dynamic Web Sites
www.dantleech.com

Bath Gigs
www.bathgigs.co.uk

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
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
-~--~~~~--~~--~--~---



[symfony-users] Re: sf1.1 form binding and wiping

2008-11-12 Thread Dan Leech

hi,

The "problem" seems to be that the sfPropelForm updateObject() { ...
object -> fromArray($this -> getValues()) } overwrites all the fields
given in the widget / validator schema, as each key is present in the
getValues() array. -- removing the widget / validator for the
corresponding field avoids the problem. Is this the intended behavior?

POST:

Array
(
[project] => Array
(
[title] => Foo
)

)

public function executeCreate($request)
  {
$project = new Project;
$project -> setRandomField('Random text');
$form = new ProjectForm($project);

if ($request -> isMethod('post'))
{
  $form -> bind($request -> getParameter('project'));

  if ($form -> isValid())
  {
print_r($form -> getObject()); // [random_field:protected] =>
Random text
$form -> save();
print_r($form -> getObject()); // [random_field:protected] =>

2008/11/12 Fabien Potencier <[EMAIL PROTECTED]>
>
> When you create the form, you pass an object. This object have the
> user_id and type set. It those columns are not in the form, they won't
> be in the POST array, so then they won't change the object when you
> bind() then save() the form. i have just tested and it works.
>
> Fabien
>
> --
> Fabien Potencier
> Sensio CEO - symfony lead developer
> sensiolabs.com | symfony-project.com | aide-de-camp.org
> Tél: +33 1 40 99 80 80
>
>
> Dan Leech wrote:
> > hi fabien
> >
> > My use case is...
> >
> > Database record:
> >
> > report:
> >   title: varchar
> >   type: varchar
> >   scale: int
> >   theme: varchar
> >   user_id: int
> >
> > On the edit page I render the title, scale and theme fields in the form.
> > The type and user_id are not part of the form, and should not change.
> >
> > I instantiate the form with the current object, with the current values:
> >
> > $form = new ReportForm($current_record);
> >
> > I bind the form with the field subset given in the POST array. The
> > "user_id" and "type" fields are then null.
> >
> > cheers
> >
> > dan
> >
> > 2008/11/12 Fabien Potencier <[EMAIL PROTECTED]
> > <mailto:[EMAIL PROTECTED]>>
> >
> >
> >
> > Dan Leech wrote:
> >  > hi all
> >  >
> >  > i think the form framework is great, but .
> >  >
> >  > When I bind a form to a request array the values in the object are
> >  > wiped, e.g. if I set the a user_id field before the bind, it is
> > set to
> >  > null after. So any data that is in the record is wiped and
> > replaced by
> >  > the data in the request array. Forcing me to add more lines of
> > code to
> >  > add missing data into the bind-data or drop the 'required' validation
> >  > and populate the values in the updateObject method.
> >  >
> >      > Is this a bug or am I just wrong?
> >
> > It is not a bug. A form has two state:
> >
> >   * A form with the default values
> >   * A bound form which is a form updated with the submitted values.
> >
> > And it does not make sense to change the submitted values. To better
> > answer your question, can you give us more information of your use case.
> >
> > Fabien
> >
> >  >
> >  > cheers
> >  >
> >  > dan
> >  >
> >  >
> >  > --
> >  > Dan Leech
> >  >
> >  > Dynamic Web Sites
> >  > www.dantleech.com <http://www.dantleech.com>
> > <http://www.dantleech.com>
> >  >
> >  > Bath Gigs
> >  > www.bathgigs.co.uk <http://www.bathgigs.co.uk>
> > <http://www.bathgigs.co.uk>
> >  >
> >  > >
> >
> >
> >
> >
> >
> > --
> > Dan Leech
> >
> > Dynamic Web Sites
> > www.dantleech.com <http://www.dantleech.com>
> >
> > Bath Gigs
> > www.bathgigs.co.uk <http://www.bathgigs.co.uk>
> >
> > >
>
>
> >



--
Dan Leech

Dynamic Web Sites
www.dantleech.com

Bath Gigs
www.bathgigs.co.uk

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
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
-~--~~~~--~~--~--~---



[symfony-users] Re: sf1.1 form binding and wiping

2008-11-12 Thread Dan Leech
hi fabien

My use case is...

Database record:

report:
  title: varchar
  type: varchar
  scale: int
  theme: varchar
  user_id: int

On the edit page I render the title, scale and theme fields in the form. The
type and user_id are not part of the form, and should not change.

I instantiate the form with the current object, with the current values:

$form = new ReportForm($current_record);

I bind the form with the field subset given in the POST array. The "user_id"
and "type" fields are then null.

cheers

dan

2008/11/12 Fabien Potencier <[EMAIL PROTECTED]>

>
>
> Dan Leech wrote:
> > hi all
> >
> > i think the form framework is great, but .
> >
> > When I bind a form to a request array the values in the object are
> > wiped, e.g. if I set the a user_id field before the bind, it is set to
> > null after. So any data that is in the record is wiped and replaced by
> > the data in the request array. Forcing me to add more lines of code to
> > add missing data into the bind-data or drop the 'required' validation
> > and populate the values in the updateObject method.
> >
> > Is this a bug or am I just wrong?
>
> It is not a bug. A form has two state:
>
>   * A form with the default values
>   * A bound form which is a form updated with the submitted values.
>
> And it does not make sense to change the submitted values. To better
> answer your question, can you give us more information of your use case.
>
> Fabien
>
> >
> > cheers
> >
> > dan
> >
> >
> > --
> > Dan Leech
> >
> > Dynamic Web Sites
> > www.dantleech.com <http://www.dantleech.com>
> >
> > Bath Gigs
> > www.bathgigs.co.uk <http://www.bathgigs.co.uk>
> >
> > >
>
> >
>


-- 
Dan Leech

Dynamic Web Sites
www.dantleech.com

Bath Gigs
www.bathgigs.co.uk

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
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
-~--~~~~--~~--~--~---



[symfony-users] sf1.1 form binding and wiping

2008-11-11 Thread Dan Leech
hi all

i think the form framework is great, but .

When I bind a form to a request array the values in the object are wiped,
e.g. if I set the a user_id field before the bind, it is set to null after.
So any data that is in the record is wiped and replaced by the data in the
request array. Forcing me to add more lines of code to add missing data into
the bind-data or drop the 'required' validation and populate the values in
the updateObject method.

Is this a bug or am I just wrong?

cheers

dan


-- 
Dan Leech

Dynamic Web Sites
www.dantleech.com

Bath Gigs
www.bathgigs.co.uk

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
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
-~--~~~~--~~--~--~---