Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manipulating PrimaryKey in Form #40

Closed
simitter opened this issue May 12, 2011 · 2 comments
Closed

Manipulating PrimaryKey in Form #40

simitter opened this issue May 12, 2011 · 2 comments
Labels

Comments

@simitter
Copy link
Contributor

It's currently possible to update other objects rather than the to the form passed object by manipulating the primaryKey Hidden field in the html-code before submitting the form.

Symfony allready fixed this issue about a year ago in the standard sfPropelPlugin. I've noticed it was never fixed in sfPropel15Plugin. Would it be possible to fix this in sfPropel15Plugin too?

Best wishes,
Tschebel

Index: lib/generator/sfPropelFormGenerator.class.php
===================================================================
--- lib/generator/sfPropelFormGenerator.class.php   (revision 4333)
+++ lib/generator/sfPropelFormGenerator.class.php   (working copy)
@@ -328,10 +328,14 @@
         $name = 'Pass';
     }
 
-    if ($column->isPrimaryKey() || $column->isForeignKey())
+    if ($column->isForeignKey())
     {
       $name = 'PropelChoice';
     }
+    else if ($column->isPrimaryKey())
+    {
+      $name = 'Choice';
+    }
 
     return sprintf('sfValidator%s', $name);
   }
@@ -353,7 +357,7 @@
     }
     else if ($column->isPrimaryKey())
     {
-      $options[] = sprintf('\'model\' => \'%s\', \'column\' => \'%s\'', $column->getTable()->getClassname(), $this->translateColumnName($column));
+      $options[] = sprintf('\'choices\' => array($this->getObject()->get%s()), \'empty_value\' => $this->getObject()->get%1$s()', $this->translateColumnName($column, false, BasePeer::TYPE_PHPNAME));
     }
     else
     {
@willdurand
Copy link
Contributor

Hi,

Could you write a pull request for that issue ?

Thanks,
William

willdurand added a commit that referenced this issue Sep 2, 2011
#40 Manipulating PrimaryKey in Form
@willdurand
Copy link
Contributor

Fixed. Thanks.

hd-deman pushed a commit to hd-deman/sfPropelORMPlugin that referenced this issue May 4, 2012
…that the behavior is much more powerful than previously thought.

Refs propelorm#40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants