English 中文(简体)
ony1.4 表格不节省带embe的外在钥匙
原标题:Symfony 1.4 forms doesn t save foreign key with embedRelation

www.un.org/Depts/DGACM/index_spanish.htm 情况:

I have a Model A and Model B. Model A has a foreign key (modelb_id) for Model B.

这两种模式都有其形式。 I m 将该《示范公约》的形式纳入A。

class ModelAForm extends ....{

  public function configure(){
    unset($this[ modelb_id ]);
    $this->embedRelation( ModelB );
  }
}

www.un.org/Depts/DGACM/index_spanish.htm 问题:

当我节省表格时,它确实节省了《示范公约》,但它并没有改变《示范法》中外国钥匙的价值(在模式A中,模型b_id仍然空出)。

Anyone has a clue?

问题回答

If you want to update related objects on Save of one form. You can override the BasesfForm::doUpdateObject method.

在阁下的表格中,增加如下内容:

 /* If you want to add some logic before updating or update other associated
  * objects, this is the method to override.
  *
  * @param array $values An array of values
  */
  public function doUpdateObject($values) {
    // Handle the normal stuff that this method does
      $this->getObject()->fromArray($values, BasePeer::TYPE_FIELDNAME);
      $obj = $this->getObject();

    // and, get the needed value
      $val = $obj->getDesiredPropertyValue();

    // use the value to update the related thing
      foreach ($obj->getRelatedObjects() as $related)
            {
              $related->setColumnNamedThing($val);
            }
   }




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签