Author: sevein
Date: Fri Aug 19 11:07:04 2011
New Revision: 9545
Log:
Improve contact information form process method in the donor component
Modified:
trunk/plugins/qtAccessionPlugin/modules/accession/actions/relatedDonorComponent.class.php
Modified:
trunk/plugins/qtAccessionPlugin/modules/accession/actions/relatedDonorComponent.class.php
==============================================================================
---
trunk/plugins/qtAccessionPlugin/modules/accession/actions/relatedDonorComponent.class.php
Fri Aug 19 11:06:01 2011 (r9544)
+++
trunk/plugins/qtAccessionPlugin/modules/accession/actions/relatedDonorComponent.class.php
Fri Aug 19 11:07:04 2011 (r9545)
@@ -23,9 +23,12 @@
public static
$NAMES = array(
'authorizedFormOfName',
- 'resource',
'type',
+ // Must be processed before the contact information fields
+ // because sets $this->contactInformation property
+ 'resource',
+
// Contact information
'city',
'contactPerson',
@@ -57,6 +60,8 @@
$this->form->setValidator('countryCode', new
sfValidatorI18nChoiceCountry);
$this->form->setWidget('countryCode', new
sfWidgetFormI18nChoiceCountry(array('add_empty' => true, 'culture' =>
$this->context->user->getCulture())));
+ break;
+
case 'city':
case 'contactPerson':
case 'email':
@@ -77,29 +82,37 @@
{
switch ($field->getName())
{
+ // Override RelationEditComponent
+ case 'resource':
+ unset($this->relation->object);
+
+ $value = $this->form->getValue('resource');
+ if (isset($value))
+ {
+ $params = $this->context->routing->parse(Qubit::pathInfo($value));
+ $this->relation->object = $params['_sf_route']->resource;
+
+ if (null === $this->contactInformation =
$this->relation->object->getPrimaryContact())
+ {
+ $this->contactInformation = new QubitContactInformation;
+ }
+ }
+
+ break;
+
case 'city':
case 'contactPerson':
+ case 'countryCode':
case 'email':
case 'postalCode':
case 'region':
case 'streetAddress':
case 'telephone':
-
- if (!isset($this->contact) && isset($this->relation->object))
- {
- if (null === $this->contact =
$this->relation->object->getPrimaryContact())
- {
- $this->contact = new QubitContactInformation;
- }
-
- }
-
- $this->contact[$field->getName()] =
$this->form->getValue($field->getName());
+ $this->contactInformation[$field->getName()] =
$this->form->getValue($field->getName());
break;
default:
-
parent::processField($field);
}
}
@@ -108,11 +121,18 @@
{
parent::processForm();
- if (isset($this->contact))
+ if (isset($this->contactInformation->city) ||
+ isset($this->contactInformation->contactPerson) ||
+ isset($this->contactInformation->email) ||
+ isset($this->contactInformation->postalCode) ||
+ isset($this->contactInformation->region) ||
+ isset($this->contactInformation->streetAddress) ||
+ isset($this->contactInformation->telephone) ||
+ isset($this->contactInformation->countryCode))
{
- $this->contact->actor = $this->relation->object;
- $this->contact->save();
- $this->contact->makePrimaryContact();
+ $this->contactInformation->actor = $this->relation->object;
+ $this->contactInformation->save();
+ $this->contactInformation->makePrimaryContact();
}
}
--
You received this message because you are subscribed to the Google Groups
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/qubit-commits?hl=en.