-
Notifications
You must be signed in to change notification settings - Fork 154
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
Notice: Undefined offset: 2 on src/App/MyBundle/Model/om/BaseComponentProductMapsQuery.php at line 241 #342
Comments
The issue seems to be on the BaseComponentProductMapsQuery function that has been prebuilt. This is Where the error occurs: /**
* Filter the query by a list of primary keys
*
* @param array $keys The list of primary key to use for the query
*
* @return ComponentProductMapsQuery The current query, for fluid interface
*/
public function filterByPrimaryKeys($keys)
{
if (empty($keys)) {
return $this->add(null, '1<>1', Criteria::CUSTOM);
}
foreach ($keys as $key) {
$cton0 = $this->getNewCriterion(ComponentProductMapsPeer::ID, $key[0], Criteria::EQUAL);
$cton1 = $this->getNewCriterion(ComponentProductMapsPeer::COMPONENT_ID, $key[1], Criteria::EQUAL);
$cton0->addAnd($cton1);
$cton2 = $this->getNewCriterion(ComponentProductMapsPeer::PRODUCT_ID, $key[2], Criteria::EQUAL);
$cton0->addAnd($cton2);
$this->addOr($cton0);
}
return $this;
} As you can see from the BaseProduct function below (part of it): protected function doSave(PropelPDO $con)
{
$affectedRows = 0; // initialize var to track total num of affected rows
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
$this->doInsert($con);
} else {
$this->doUpdate($con);
}
$affectedRows += 1;
$this->resetModified();
}
if ($this->componentsScheduledForDeletion !== null) {
if (!$this->componentsScheduledForDeletion->isEmpty()) {
$pks = array();
$pk = $this->getPrimaryKey();
foreach ($this->componentsScheduledForDeletion->getPrimaryKeys(false) as $remotePk) {
$pks[] = array($pk, $remotePk);
}
ComponentProductMapsQuery::create()
->filterByPrimaryKeys($pks)
->delete($con);
$this->componentsScheduledForDeletion = null;
}
foreach ($this->getComponents() as $component) {
if ($component->isModified()) {
$component->save($con);
}
}
} elseif ($this->collComponents) {
foreach ($this->collComponents as $component) {
if ($component->isModified()) {
$component->save($con);
}
}
} From the line I fixed it by wrapping the BaseComponentProductMapsQuery in an if statement if (count($key) == 2){
$cton1 = $this->getNewCriterion(ComponentProductMapsPeer::COMPONENT_ID, $key[1], Criteria::EQUAL);
$cton2 = $this->getNewCriterion(ComponentProductMapsPeer::PRODUCT_ID, $key[0], Criteria::EQUAL);
$cton1->addAnd($cton2);
$this->addOr($cton1);
}else{
// original code
} As I'm not sure if this original code is actually needed or not and it's only a temporary fix as when I rebuild the model it will work. There more than likely will be a more elegant solution to this. |
I can change the options that component without a problem using the generated check boxes however, if I decide that I want to untick all of the checkboxes then I get the following error:
Stack Trace:
Schema:
FormBuilder section of the Form:
The text was updated successfully, but these errors were encountered: