Re: [symfony-users] help with action preExecute() and forward()

2010-09-01 Thread Syam

Hi,

You should use a component slot.

Regards,

On 09/01/2010 10:10 AM, Cyrille37 wrote:

Hello,
After read some posts, I'd learned the rule that one action for one
template.
So I now need some architect's ideas to solve a case.

To fill a slot used in the layout, I call a DB Query in the
action::preExecute().

But when there is an action::forward(), this preExecute() is called
twice, and so the DB Query too. That's the problem :
   - Where may I put the DB Query ?
   - Where to fill the slot ?

thanks a lot for your lights ;-)
Cyrille.

   


--
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] prefill login form

2010-03-23 Thread Syam
Extend the sfGuardFormSignin.class.php from sfDoctrineGuardPlugin, and 
in the configure method, use the setDefault('username', $value) method 
to what value you want ...


example :

class signinForm extends sfGuardFormSignin
{
 public function configure()
 {
   parent::configure();

   $this-setDefault('username', 'your login');
 }
}

Lea Hänsenberger wrote:

anyone?

On Mar 22, 2010, at 16:47 , Lea Haensenberger wrote:

  

Hi all,
I'd like to pre-fill the username of the sfDoctrineGuardPlugin login
form, after the user registered and confirmed his email. Is there an
easy way to pre-fill values in the login form or do I have to override
the executeSignin action of the plugin?

Cheers,
Lea

--
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

To unsubscribe from this group, send email to symfony-users+unsubscribegooglegroups.com 
or reply to this email with the words REMOVE ME as the subject.



  


--
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

To unsubscribe from this group, send email to symfony-users+unsubscribegooglegroups.com 
or reply to this email with the words REMOVE ME as the subject.


Re: [symfony-users] how to create a copy of symfony app using a different database

2010-03-22 Thread Syam
application :  You mean real app in apps/ or complete symfony project 
to copy ?


Peter Peltonen wrote:

A newbie question: how do I create a copy of symfony app using a
different database? Here is what I tried:

1) copied my symfony 1.2.12 application to another dir to make a copy of it.

2) did a dump of the MySQL database used by the original symfony app
and created a new db where I inserted the data from the dump

3) For the new symfony application I changed the new database name in
config/databases.yml

4) Tried inserting data using a form in thew new app

= Problem: the data was inserted in the original symfony app's db,
not into the new one

Best regards,
Peter

  


--
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

To unsubscribe from this group, send email to symfony-users+unsubscribegooglegroups.com 
or reply to this email with the words REMOVE ME as the subject.


Re: [symfony-users] Select fields updating other form fields

2010-03-22 Thread Syam

I did this feature on a car site :
http://www.groupe-lempereur.com

On the upper right, you can find 4 select fields, with the model 
(modèle) field depending from the mark (marque) field through ajax.


*The code :*

In action.class.php :

public function executeSearch()
{
 $user = $this-getUser();
 $this-form = new searchForm();
 $this-form-bind($this-getRequestParameter('search'));
}

public function executeAjaxModel($request)
{
 $this-form = new searchForm();
 $this-form-bind();
}


in searchSuccess.php :

form action=?=url_for('@search_result')? method=post
 table cellpadding=0 cellspacing=0
   trtd?=$form['mark_id']-renderLabel() 
??=$form['mark_id']-render() ?/td/tr
   trtd?=$form['model_id']-renderLabel() 
??=$form['model_id']-render() ?/td/tr
   trtd?=$form['price']-renderLabel() 
??=$form['price']-render() ?/td/tr
   trtd?=$form['fuel_id']-renderLabel() 
??=$form['fuel_id']-render() ?/td/tr


   ? if($extended): ?
 trtd?=$form['bodywork_id']-renderLabel() 
??=$form['bodywork_id']-render() ?/td/tr

   ? else: ?
 tr
   tdinput type=submit class=button value=/td
 /tr
   ? endif ?

 /table
   /form

   script type=text/javascript
   jQuery('#search_mark_id').change(function(e) {
 jQuery.post
   (
 '?=url_for('@search_ajax_model') ?',
 {mark_id: jQuery('#search_mark_id').val()},
 function(html){jQuery('#search_model_id').replaceWith(html);},
 'html'
   );
   });
   /script


In ajaxModelSuccess.php :

?=$form['model_id']-render()?


In searchForm.class.php :

class searchForm extends BaseFormDoctrine
{
 public function setup()
 {
   parent::setup();

   $q = Doctrine::getTable('model')-queryAllUsed()-orderBy('m2.name 
ASC, m.name ASC');


   $request = sfContext::getInstance()-getRequest();
   $mark_id = $request-getParameter('search[mark_id]' 
,$request-getParameter('mark_id'));

   if($mark_id) $q-addWhere('m.mark_id = ?', $mark_id);
  
   $select_empty = '-- Indifférent --';

   $select_prices = array(
 '' = $select_empty,
 '0:5000' = 'Moins de 5.000EUR',
 '5000:1' = 'de 5.000EUR à 10.000EUR',
 '1:15000' = 'de 10.000EUR à 15.000EUR',
 '15000:2' = 'de 15.000EUR à 20.000EUR',
 '2:+' = 'Plus de 20.000EUR',
   );
  
   $this-setWidgets(array(
 'price'= new sfWidgetFormChoice(array('choices' = 
$select_prices)),
 'mark_id' = new sfWidgetFormDoctrineSelect(array('model' = 
'mark', 'add_empty' = $select_empty, 'query' = 
Doctrine::getTable('mark')-queryAllUsed())),
 'bodywork_id' = new sfWidgetFormDoctrineSelect(array('model' = 
'bodywork', 'add_empty' = $select_empty, 'order_by' = 
array('name','asc'))),
 'fuel_id' = new sfWidgetFormDoctrineSelect(array('model' = 
'fuel', 'add_empty' = $select_empty, 'order_by' = array('name','asc'))),
 'model_id' = new sfWidgetFormDoctrineChoice(array('model' = 
'model', 'add_empty' = $select_empty, 'query' = $q)),

   ));

   $this-setValidators(array(
 'price'  = new sfValidatorChoice(array('choices' = 
array_keys($select_prices), 'required' = false)),
 'mark_id' = new sfValidatorDoctrineChoice(array('model' = 
'mark', 'required' = false)),
 'bodywork_id' = new sfValidatorDoctrineChoice(array('model' = 
'bodywork', 'required' = false)),
 'fuel_id' = new sfValidatorDoctrineChoice(array('model' = 
'fuel', 'required' = false)),
 'model_id' = new sfValidatorDoctrineChoice(array('model' = 
'model', 'required' = false)),

   ));
  
   $this-widgetSchema-setLabel('price', 'Prix');

   $this-widgetSchema-setLabel('mark_id', 'Marque');
   $this-widgetSchema-setLabel('bodywork_id', 'Carrosserie');
   $this-widgetSchema-setLabel('fuel_id', 'Carburation');
   $this-widgetSchema-setLabel('model_id', 'Modèle');
  
   $this-widgetSchema-setPositions(array('bodywork_id', 'mark_id', 
'price', 'fuel_id', 'model_id'));


   $this-widgetSchema-setNameFormat('search[%s]');

   $this-errorSchema = new sfValidatorErrorSchema($this-validatorSchema);


 }

 public function getModelName()
 {
   return 'vehicle';
 }
}


Note that theses lines are very bads :

   $request = sfContext::getInstance()-getRequest();
   $mark_id = $request-getParameter('search[mark_id]' 
,$request-getParameter('mark_id'));


You should use form option feature instead with getOption() and 
setOption() methods.



bretth wrote:

Hi all,

I need to make a form which has a number of select fields; changing
one field causes the second select field to reload with a number of
sub items based on what was selected in the first. Ie Selecting a
Category from the first select field updates the Subcategories select
field 

Re: [symfony-users] Symfony routing and _

2010-03-16 Thread Syam

Hi,

In your factories.yml application config file, you can use the 
segment_separators option on routing section :


all:
 routing:
   class: sfPatternRouting
   param:
 generate_shortest_url: true
 extra_parameters_as_query_string: true
 segment_separators: ['.','/','_']

Hope this help.

DarrenMr wrote:

Does symfony routing allow _? My routing config is below, it works
with / but not _

product_view:
  url: /product_:brand/:name
  param: { module: products, action: view }
  requirements: { brand: \d+, name: .+ }

name when I call it does not have any _

Does anyone know how to fix this?

Thanks,
Darren

  


--
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] help il list

2010-03-13 Thread Syam

I am not sure to understand,

You want to retreive category from the existing job ? right ?

But if this is the case, what about the first record ? You won't have 
any existing category, does not make sense ... (or you have to display a 
select input and a free text input, then get the value from one of the 
two fields ...)


I think you should create a jobCategory model whith one-to-many relation 
to your job model, this is a simplier way and faster to execute :


job:
 connection: doctrine
 tableName: job
 columns:
   id_marchandise:
 type: integer(4)
 primary: true
 autoincrement: true
  job_category_id: integer
  sub_category:
 type: string(50)
 relations:
   jobCategory:
 type: one
 foreignType: many
 onDelete: SET NULL

jobCategory:
 columns:
   name: string(128)



Belgacem TLILI wrote:

i have this class
job:
  connection: doctrine
  tableName: job
  columns:
id_marchandise:
  type: integer(4)
  primary: true
  autoincrement: true
   category:
  type: string(50)
   sub_category:
  type: string(50)

i would like have the data  of this table in (of my database) like a
list of option in indexSuccess.php

like this in html

select name=job[category] id=job_category
option value=1Petit Colis/option
option value=2Moyen Colis/option
option value=3Grand Colis/option

//the data from database

option value=7Petite Palette/option
option value=8Moyenne Palette/option
option value=9Grande Palette/option
/select

how can i do this

how can i build a doctrine request (DQL)

  


--
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] Doctrine question

2010-03-12 Thread Syam

Hi,

Try this :

Channel:
 actAs: { Timestampable: ~ }
 columns:
   sender_id: { type: integer, notnull: true }
   receiver_id: { type: integer, notnull: true }
 relations:
   SenderProfile: { local: sender_id, foreign: id, class: Profile}
   ReceiverProfile: { local: receiver_id, foreign: id, class: Profile}


//Syam



Alexander Deruwe wrote:

I have the following yaml schema:

Profile:
  # blah blah

Channel:
  actAs: { Timestampable: ~ }
  columns:
sender_id: { type: integer, notnull: true }
receiver_id: { type: integer, notnull: true }
  relations:
Profile: { local: sender_id, foreign: id }

How can I relate receiver_id to the same Profile table as sender_id?

Cheers,


A.

  


--
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] sfWidgetFormDoctrineChoice problems

2010-03-06 Thread Syam

Hi,

You can use the sfWidgetFormDoctrineChoice widget with the 'query' 
option, thus, you can pass params to your query throught the form option 
system :


*In action :*
$this-form = new campaignForm($record, array('organization' = 
$user-organization) // or any param you want from $request object


*In form :*
$query = 
Doctrine::getTable('Campaign')-getCampaignsQuery($this-getOption('organization'))


$this-widgetSchema['campaign_id'] = new sfWidgetFormDoctrineChoice(array
   (
   'model' = 'Campaign',
   'query' = $query
   ));

Hope it help you.

Samuel Morhaim wrote:
I have a question, I have a dropdown that needs to be populated from 
the database, but with a query, and the query is based on a post 
variable.


I know that sfWidgetFormDoctrineChoice has an option for passing a 
method, but I can't pass a method + parameter like that.


So I used the simple sfWidgetFormChoice with the choice value being 
the Doctrine getTable  and the parameter..  as shown in the bottom of 
this email..  HOWEVER, the dropdown is not well populated.  The 
dropdown is formed like this:


option value=020 Off Code/option
option value=1Special Sale/option
option value=230 Off/option

This is incorrect, since the value for 20 Off Code is not 0 , is 
actually 1  so the index is wrong.


$this-widgetSchema['campaign_id'] = new sfWidgetFormChoice(array
(
'choices' = 
Doctrine::getTable('Campaign')-getCampaigns(sfContext::getInstance()-getUser()-getGuardUser()-Organization)

));


What can I do ?

Thank you.

--
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


--
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] sfWidgetFormDoctrineChoice problems

2010-03-06 Thread Syam


You have to pass a Doctrine query to the widget, not a Doctrine collection.
(Note the Query part in my getCampaignsQuery() table method example.)

Samuel Morhaim wrote:

Syam.. that didnt work it gives me an error.

$query = 
Doctrine::getTable('Campaign')-getCampaigns(sfContext::getInstance()-getUser()-getGuardUser()-Organization);
   
$this-widgetSchema['campaign_id'] = new 
sfWidgetFormDoctrineChoice(array

(
'model' = 'Campaign',
'query' = $query
));


*Fatal error*: Call to undefined method Doctrine_Collection::execute() 
in 
*/usr/local/share/symfony-1.4/lib/plugins/sfDoctrinePlugin/lib/widget/sfWidgetFormDoctrineChoice.class.php* 
on line *86



*Let me know..

I went around it by adding INDEXBY to the query... but i dont think 
its clean to do it this way without using the doctrine widget.


public function getCampaigns(Organization $organization = null)
{
$q = Doctrine_Query::create()
  -from('Campaign c INDEXBY c.id http://c.id')
  -where('c.organization_id =?', $organization-id);
 
return $q-execute();

}



On Sat, Mar 6, 2010 at 8:44 AM, Syam s...@nexen.org 
mailto:s...@nexen.org wrote:


Hi,

You can use the sfWidgetFormDoctrineChoice widget with the 'query'
option, thus, you can pass params to your query throught the form
option system :

*In action :*
$this-form = new campaignForm($record, array('organization' =
$user-organization) // or any param you want from $request object

*In form :*
$query =

Doctrine::getTable('Campaign')-getCampaignsQuery($this-getOption('organization'))

$this-widgetSchema['campaign_id'] = new
sfWidgetFormDoctrineChoice(array
(
'model' = 'Campaign',
'query' = $query
));

Hope it help you.

Samuel Morhaim wrote:

I have a question, I have a dropdown that needs to be populated
from the database, but with a query, and the query is based on a
post variable.

I know that sfWidgetFormDoctrineChoice has an option for passing
a method, but I can't pass a method + parameter like that.

So I used the simple sfWidgetFormChoice with the choice value
being the Doctrine getTable  and the parameter..  as shown in the
bottom of this email..  HOWEVER, the dropdown is not well
populated.  The dropdown is formed like this:

option value=020 Off Code/option
option value=1Special Sale/option
option value=230 Off/option

This is incorrect, since the value for 20 Off Code is not 0 , is
actually 1  so the index is wrong.

$this-widgetSchema['campaign_id'] = new sfWidgetFormChoice(array
(
'choices' =

Doctrine::getTable('Campaign')-getCampaigns(sfContext::getInstance()-getUser()-getGuardUser()-Organization)
));


What can I do ?

Thank you.

-- 
If you want to report a vulnerability issue on symfony, please

send it to security at symfony-project.com
http://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
mailto:symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
mailto:symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en
-- 
If you want to report a vulnerability issue on symfony, please

send it to security at symfony-project.com
http://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 mailto:symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
mailto:symfony-users%2bunsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


--
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


--
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

Re: [symfony-users] sfValidatorChoice always invalid!!

2010-02-19 Thread Syam

You must only pass the keys of your $modulo array to validator :

$this-validatorSchema['id_modulo'] = new sfValidatorChoice(
  array('choices'  = array_keys($modulos))
);


wueb wrote:

Hi mates,

I'm having a problem in this piece of code:

$modulos = array ( 1 = option 1, 2 = option 2);

$this-widgetSchema['id_modulo'] = new sfWidgetFormSelectCheckbox(
array('choices'  = $modulos)
);

$this-validatorSchema['id_modulo'] = new sfValidatorChoice(
array('choices'  = $modulos)
);


I have a checkbox and a validator. The problem is when i submit the
form, the checkbox validator send me always a Invalid. message!!

Anyone have a idea why is this happening?

  


--
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.



Re: [symfony-users] Resize images while upload without plugin

2010-02-19 Thread Syam

Hi,

You can write your own class extending the sfValidatedFile class and put 
your code in it.


You can found an concrete example on the excellent Symfony in the 
Cloud slides from Kris Wallsmith at sfLive2010
http://www.slideshare.net/kriswallsmith/symfony-in-the-cloud (class 
example at slide 64)


Antoine Delorme wrote:

Hi there,

I got a problem, i'm trying to do a resize on images while I upload
them. My problem there is i don't know where do I put my code to
resize the picture, and how to save the caption in the db.

I Already got the code for the resize and it work (it's from an old
website of mine).

I was thinking do it by widget and validator, but even with the more
with symfony book, i don't really understand how to do it.

Could someone help me please?

If you need part of my code i will be happy to give it!

  


--
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.



Re: [symfony-users] Re: Id being lost on update..

2010-02-18 Thread Syam

Take a look :/

$request-getParameter('id')));/

Don't think it's correct because symfony framework use an array 
container for submitted values.
Regarding your model, you should have something like campaign[] POST 
container.


So to get the posted id from current record, and assuming you are using 
the 1.3/1.4 symfony version, you need to do this :


/$params = $request-getParameter(campaign);
$id = $params['id'];/

($request-getParameter(campaign[id]) is deprecated and does not work 
anymore in symfony 1.4)


Samuel Morhaim wrote:

Here goes the extra info. :)

1. I am just doing a simple edit.  (based almost on the generated CRUD actions)
2. Yes, it is unique, (schema below).
3. I am NOT trying to update/modify the ID since it is unique, etc.
THAT IS the problem.. for some reason it trying to set the ID to
empty. OR should not be updating the ID at all, but it is doing it




Actions:

  public function executeEdit(sfWebRequest $request)
  {
$this-forward404Unless($campaign =
Doctrine::getTable('Campaign')-find(array($request-getParameter('id'))),
sprintf('Object campaign does not exist (%s).',
$request-getParameter('id')));
$this-form = new CampaignForm($campaign);
  }

  public function executeUpdate(sfWebRequest $request)
  {
$this-forward404Unless($request-isMethod(sfRequest::POST) ||
$request-isMethod(sfRequest::PUT));
$this-forward404Unless($campaign =
Doctrine::getTable('Campaign')-find(array($request-getParameter('id'))),
sprintf('Object campaign does not exist (%s).',
$request-getParameter('id')));
$this-form = new CampaignForm($campaign);

$this-processForm($request, $this-form);

$this-campaigns =
Doctrine::getTable('Campaign')-getCampaigns($this-getUser()-getGuardUser()-Organization);
$this-setLayout(AJAX_ENABLED);
return $this-renderPartial('campaign/list', array('campaigns' =
$this-campaigns));
  }

  protected function processForm(sfWebRequest $request, sfForm $form)
  {
$form-bind($request-getParameter($form-getName()),
$request-getFiles($form-getName()));
if ($form-isValid())
{
  $campaign = $form-save();

}
  }



==


SCHEMA

Campaign:
  columns:
id:
  primary: true
  unique: true
  type: integer
  notnull: true
  autoincrement: true
organization_id:
  type: integer
  notnull: true
name:
  unique: false
  type: string(255)
  notnull: true
description:
  type: blob(0)
is_active:
  default: true
  type: boolean
  notnull: true
  indexes:
IX_Campaign_1:
  fields: [id]
IX_Campaign_2:
  fields: [is_active]
  relations:
Organization:
  local: organization_id
  foreign: id



===



2010/2/18 Michał Piotrowski mkkp...@gmail.com:
  

I'm wondering why do you want to update id? I assume that you are
using id as primary key, so updating it to other value just doesn't
makes sense.

Maybe someone will help you if you explain what do you want to do.
Actually we don't have enough information on such things as:
- what do you want to do
- what you are doing - iow - show us the code - maybe others are, but
I'm not a seer :)

Regards,
Michal

2010/2/18 Samuel Morhaim samuel.morh...@gmail.com:


Anyone?

On 2/17/10, Samuel Morhaim samuel.morh...@gmail.com wrote:
  

If it helps.. this is the error, of course because it lost the id..

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry
'0' for key 1
stack trace

* at ()
  in
SF_SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection.php
line 1082 ...
1079. $message .= sprintf('. Failing Query:
%s', $query);





On Wed, Feb 17, 2010 at 5:20 PM, Samuel Morhaim
samuel.morh...@gmail.com wrote:


I am getting an error when doing a simple edit/update ... the ID of
the item is being lost.

This is the DB log... maybe somebody can help ?


#

SELECT c.id AS c__id, c.organization_id AS c__organization_id, c.name
AS c__name, c.description AS c__description, c.is_active AS
c__is_active FROM campaign c WHERE (c.id = '2') LIMIT 1
0.00s, doctrine connection Toggle debug stack
#23 » in sfDoctrineConnectionProfiler-preStmtExecute() from
SF_SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/EventListener/Chain.php
line 494
#22 » in Doctrine_EventListener_Chain-preStmtExecute() from
SF_SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/Statement.php
line 231
#21 » in Doctrine_Connection_Statement-execute() from
SF_SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection.php
line 1006
#20 » in Doctrine_Connection-execute() from
SF_SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Query/Abstract.php
line 976
#19 » in Doctrine_Query_Abstract-_execute() from
SF_SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Query/Abstract.php
line 1026
#18 » in Doctrine_Query_Abstract-execute() from

Re: [symfony-users] Re: Id being lost on update..

2010-02-18 Thread Syam
If you forgot echo $form-renderHiddenFields();, then 
unset($this[id]) make sense since the validator don't try to taint 
the missing value.


Can you paste your template code please ?

Samuel Morhaim wrote:

unseting id worked..  However.. why is this necessary? The generated
Crud, did not do this initially, why is it necessary now? because i
unsetted one element, then i always need to unset id and such ?



On Thu, Feb 18, 2010 at 11:09 AM, Germana Oliveira
germanaolivei...@gmail.com wrote:
  

what about:

unset(
 .
 $this['id']
 );


2010/2/18 Daniel Lohse annismcken...@googlemail.com


Maybe yu forgot to do echo $form-renderHiddenFields(); in your form so
the ID that's already assigned to the object is not transmitted when
submitting the form?

Daniel

On 18.02.2010, at 16:57, Samuel Morhaim wrote:

  

?php

/**
* Campaign Entry Form.
*/

class CampaignForm extends BaseCampaignForm
{
 public function configure()
 {
   unset(
 $this['organization_id'],
 $this['is_active']
 );


 }
}



On Thu, Feb 18, 2010 at 10:42 AM, Gábor Fási maerl...@gmail.com wrote:


This looks fine. Can we see your form's configure() method?

On Thu, Feb 18, 2010 at 16:08, Samuel Morhaim
samuel.morh...@gmail.com wrote:
  

Here goes the extra info. :)

1. I am just doing a simple edit.  (based almost on the generated CRUD
actions)
2. Yes, it is unique, (schema below).
3. I am NOT trying to update/modify the ID since it is unique, etc.
THAT IS the problem.. for some reason it trying to set the ID to
empty. OR should not be updating the ID at all, but it is doing it




Actions:

 public function executeEdit(sfWebRequest $request)
 {
   $this-forward404Unless($campaign =

Doctrine::getTable('Campaign')-find(array($request-getParameter('id'))),
sprintf('Object campaign does not exist (%s).',
$request-getParameter('id')));
   $this-form = new CampaignForm($campaign);
 }

 public function executeUpdate(sfWebRequest $request)
 {
   $this-forward404Unless($request-isMethod(sfRequest::POST) ||
$request-isMethod(sfRequest::PUT));
   $this-forward404Unless($campaign =

Doctrine::getTable('Campaign')-find(array($request-getParameter('id'))),
sprintf('Object campaign does not exist (%s).',
$request-getParameter('id')));
   $this-form = new CampaignForm($campaign);

   $this-processForm($request, $this-form);

   $this-campaigns =

Doctrine::getTable('Campaign')-getCampaigns($this-getUser()-getGuardUser()-Organization);
   $this-setLayout(AJAX_ENABLED);
   return $this-renderPartial('campaign/list', array('campaigns' =
$this-campaigns));
 }

 protected function processForm(sfWebRequest $request, sfForm $form)
 {
   $form-bind($request-getParameter($form-getName()),
$request-getFiles($form-getName()));
   if ($form-isValid())
   {
 $campaign = $form-save();

   }
 }



==


SCHEMA

Campaign:
 columns:
   id:
 primary: true
 unique: true
 type: integer
 notnull: true
 autoincrement: true
   organization_id:
 type: integer
 notnull: true
   name:
 unique: false
 type: string(255)
 notnull: true
   description:
 type: blob(0)
   is_active:
 default: true
 type: boolean
 notnull: true
 indexes:
   IX_Campaign_1:
 fields: [id]
   IX_Campaign_2:
 fields: [is_active]
 relations:
   Organization:
 local: organization_id
 foreign: id



===



2010/2/18 Michał Piotrowski mkkp...@gmail.com:


I'm wondering why do you want to update id? I assume that you are
using id as primary key, so updating it to other value just doesn't
makes sense.

Maybe someone will help you if you explain what do you want to do.
Actually we don't have enough information on such things as:
- what do you want to do
- what you are doing - iow - show us the code - maybe others are, but
I'm not a seer :)

Regards,
Michal

2010/2/18 Samuel Morhaim samuel.morh...@gmail.com:
  

Anyone?

On 2/17/10, Samuel Morhaim samuel.morh...@gmail.com wrote:


If it helps.. this is the error, of course because it lost the id..

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate
entry
'0' for key 1
stack trace

* at ()
  in

SF_SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection.php
line 1082 ...
1079. $message .= sprintf('. Failing Query:
%s', $query);





On Wed, Feb 17, 2010 at 5:20 PM, Samuel Morhaim
samuel.morh...@gmail.com wrote:
  

I am getting an error when doing a simple edit/update ... the ID
of
the item is being lost.

This is the DB log... maybe somebody can help ?


#

SELECT c.id AS c__id, c.organization_id AS c__organization_id,
c.name
AS c__name, c.description AS c__description, c.is_active AS
c__is_active FROM campaign c WHERE (c.id = '2') LIMIT 1
0.00s, doctrine connection Toggle debug stack
#23 » in sfDoctrineConnectionProfiler-preStmtExecute() from