comanage-dev - [comanage-dev] r648 - in registry/trunk/app: Config/Schema Controller Lib Model View/CoEnrollmentAttributes View/CoPetitions
Subject: COmanage Developers List
List archive
[comanage-dev] r648 - in registry/trunk/app: Config/Schema Controller Lib Model View/CoEnrollmentAttributes View/CoPetitions
Chronological Thread
- From:
- To:
- Subject: [comanage-dev] r648 - in registry/trunk/app: Config/Schema Controller Lib Model View/CoEnrollmentAttributes View/CoPetitions
- Date: Mon, 23 Dec 2013 18:53:23 -0500
Author: benno
Date: 2013-12-23 18:53:23 -0500 (Mon, 23 Dec 2013)
New Revision: 648
Modified:
registry/trunk/app/Config/Schema/schema.xml
registry/trunk/app/Controller/AppController.php
registry/trunk/app/Lib/lang.php
registry/trunk/app/Model/Address.php
registry/trunk/app/Model/AppModel.php
registry/trunk/app/Model/CoEnrollmentAttribute.php
registry/trunk/app/Model/CoGroupMember.php
registry/trunk/app/Model/CoPerson.php
registry/trunk/app/Model/CoPersonRole.php
registry/trunk/app/Model/CoPetition.php
registry/trunk/app/Model/EmailAddress.php
registry/trunk/app/Model/Identifier.php
registry/trunk/app/Model/Name.php
registry/trunk/app/Model/OrgIdentity.php
registry/trunk/app/Model/TelephoneNumber.php
registry/trunk/app/View/CoEnrollmentAttributes/fields.inc
registry/trunk/app/View/CoPetitions/petition-attributes.inc
Log:
Option to require family name in enrollment flows (CO-704) and refactoring of
dynamic validation (CO-353)
Modified: registry/trunk/app/Config/Schema/schema.xml
===================================================================
--- registry/trunk/app/Config/Schema/schema.xml 2013-12-21 23:56:11 UTC (rev
647)
+++ registry/trunk/app/Config/Schema/schema.xml 2013-12-23 23:53:23 UTC (rev
648)
@@ -596,6 +596,7 @@
<notnull />
</field>
<field name="required" type="I" />
+ <field name="required_fields" type="C" size="160" />
<field name="ordr" type="I" />
<field name="hidden" type="L" />
<field name="copy_to_coperson" type="L" />
Modified: registry/trunk/app/Controller/AppController.php
===================================================================
--- registry/trunk/app/Controller/AppController.php 2013-12-21 23:56:11
UTC (rev 647)
+++ registry/trunk/app/Controller/AppController.php 2013-12-23 23:53:23
UTC (rev 648)
@@ -803,7 +803,7 @@
foreach(array_keys($model->validate) as $k)
{
- if(isset($model->validate[$k]['rule']) &&
$model->validate[$k]['rule'][0] == 'boolean')
+ if(isset($model->validate[$k]['content']['rule']) &&
$model->validate[$k]['content']['rule'][0] == 'boolean')
{
if($r[$m][$k])
$rr[$m][$k] = (bool)true;
@@ -898,8 +898,8 @@
// Convert any booleans
foreach(array_keys($model->validate) as $k) {
- if(isset($model->validate[$k]['rule'])
- && $model->validate[$k]['rule'][0] == 'boolean') {
+ if(isset($model->validate[$k]['content']['rule'])
+ && $model->validate[$k]['content']['rule'][0] == 'boolean') {
if($ret[$req][$k] == 'True')
$ret[$req][$k] = true;
else
Modified: registry/trunk/app/Lib/lang.php
===================================================================
--- registry/trunk/app/Lib/lang.php 2013-12-21 23:56:11 UTC (rev 647)
+++ registry/trunk/app/Lib/lang.php 2013-12-23 23:53:23 UTC (rev 648)
@@ -399,6 +399,7 @@
'er.et.default' => 'Failed to add default types',
'er.et.exists' => 'An extended type named "%1$s" already exists',
'er.et.inuse' => 'The extended type "%1$s" is in use by at least one
attribute within this CO and cannot be removed.',
+ 'er.field.req' => 'This field is required',
'er.fields' => 'Please recheck the highlighted fields',
'er.file.write' => 'Unable to open "%1$s" for writing',
'er.gr.exists' => 'A group named "%1$s" already exists within the CO',
@@ -456,6 +457,7 @@
'fd.address.locality' => 'City',
'fd.address.postal_code' => 'ZIP/Postal Code',
'fd.address.state' => 'State',
+ 'fd.address.fields.req' => 'An address must consist of at least these
fields:',
'fd.admin' => 'Administrator',
'fd.affiliation' => 'Affiliation',
'fd.an.desc' => 'Alphanumeric characters only',
@@ -474,7 +476,6 @@
'fd.cou.nopar' => 'No COUs are available to be assigned parent',
'fd.co_people.status' => 'CO Person Status',
'fd.created' => 'Created',
-
// Demographics fields
'fd.de.persid' => 'Person ID',
'fd.de.gender' => 'Gender',
@@ -482,6 +483,7 @@
'fd.de.ethnic' => 'Ethnicity',
'fd.de.race' => 'Race',
'fd.de.disab' => 'Disability',
+ 'fd.default' => 'Default',
'fd.desc' => 'Description',
'fd.directory' => 'Directory',
'fd.domain' => 'Domain',
@@ -627,6 +629,7 @@
'fd.name.suffix' => 'Suffix',
'fd.name.language' => 'Language',
'fd.name.primary_name' => 'Primary',
+ 'fd.name.fields.req' => 'A name must consist of at least these fields:',
'fd.no' => 'No',
'fd.null' => 'Null',
'fd.o' => 'Organization',
@@ -641,6 +644,7 @@
'fd.plugin' => 'Plugin',
'fd.plugin.ptwarn' => 'Once a Provisioning Target has been created, the
Plugin cannot be changed',
'fd.prov.status.for' => 'Provisioning Status for %1$s',
+ 'fd.pt.required' => '† denotes required fields if you populate this
section',
'fd.req' => '* denotes required field',
'fd.required' => 'Required',
'fd.roles' => 'Roles',
Modified: registry/trunk/app/Model/Address.php
===================================================================
--- registry/trunk/app/Model/Address.php 2013-12-21 23:56:11 UTC (rev
647)
+++ registry/trunk/app/Model/Address.php 2013-12-23 23:53:23 UTC (rev
648)
@@ -47,57 +47,80 @@
public $order = array("line1");
// Validation rules for table elements
+ // Validation rules must be named 'content' for petition dynamic rule
adjustment
public $validate = array(
// Don't require any element since $belongsTo saves won't validate if
they're empty
'line1' => array(
- 'rule' => array('maxLength', 128),
- 'required' => false,
- 'allowEmpty' => false
+ 'content' => array(
+ 'rule' => array('maxLength', 128),
+ 'required' => false,
+ 'allowEmpty' => false
+ )
),
'line2' => array(
- 'rule' => array('maxLength', 128),
- 'required' => false,
- 'allowEmpty' => true
+ 'content' => array(
+ 'rule' => array('maxLength', 128),
+ 'required' => false,
+ 'allowEmpty' => true
+ )
),
'locality' => array(
- 'rule' => array('maxLength', 128),
- 'required' => false,
- 'allowEmpty' => true
+ 'content' => array(
+ 'rule' => array('maxLength', 128),
+ 'required' => false,
+ 'allowEmpty' => true
+ )
),
'state' => array(
- 'rule' => array('maxLength', 128),
- 'required' => false,
- 'allowEmpty' => true
+ 'content' => array(
+ 'rule' => array('maxLength', 128),
+ 'required' => false,
+ 'allowEmpty' => true
+ )
),
'postal_code' => array(
- 'rule' => array('maxLength', 16),
- 'required' => false,
- 'allowEmpty' => true
+ 'content' => array(
+ 'rule' => array('maxLength', 16),
+ 'required' => false,
+ 'allowEmpty' => true
+ )
),
'country' => array(
- 'rule' => array('maxLength', 128),
- 'required' => false,
- 'allowEmpty' => true
+ 'content' => array(
+ 'rule' => array('maxLength', 128),
+ 'required' => false,
+ 'allowEmpty' => true
+ )
),
'type' => array(
- 'rule' => array('inList', array(ContactEnum::Home,
- ContactEnum::Office,
- ContactEnum::Postal)),
- 'required' => false,
- 'allowEmpty' => true
+ 'content' => array(
+ 'rule' => array('inList', array(ContactEnum::Home,
+ ContactEnum::Office,
+ ContactEnum::Postal)),
+ 'required' => false,
+ 'allowEmpty' => true
+ )
),
'language' => array(
- 'rule' => array('validateLanguage'),
- 'required' => false,
- 'allowEmpty' => true
+ 'content' => array(
+ 'rule' => array('validateLanguage'),
+ 'required' => false,
+ 'allowEmpty' => true
+ )
),
'co_person_role_id' => array(
- 'rule' => 'numeric',
- 'required' => false
+ 'content' => array(
+ 'rule' => 'numeric',
+ 'required' => false,
+ 'allowEmpty' => true
+ )
),
'org_identity_id' => array(
- 'rule' => 'numeric',
- 'required' => false
+ 'content' => array(
+ 'rule' => 'numeric',
+ 'required' => false,
+ 'allowEmpty' => true
+ )
)
);
Modified: registry/trunk/app/Model/AppModel.php
===================================================================
--- registry/trunk/app/Model/AppModel.php 2013-12-21 23:56:11 UTC (rev
647)
+++ registry/trunk/app/Model/AppModel.php 2013-12-23 23:53:23 UTC (rev
648)
@@ -72,16 +72,16 @@
$ret = null;
- if(isset($this->validate['type']['rule'])
- && is_array($this->validate['type']['rule'])
- && $this->validate['type']['rule'][0] == 'validateExtendedType'
- && is_array($this->validate['type']['rule'][1])
- && isset($this->validate['type']['rule'][1]['default'])) {
+ if(isset($this->validate['type']['content']['rule'])
+ && is_array($this->validate['type']['content']['rule'])
+ && $this->validate['type']['content']['rule'][0] ==
'validateExtendedType'
+ && is_array($this->validate['type']['content']['rule'][1])
+ && isset($this->validate['type']['content']['rule'][1]['default'])) {
// Figure out which language key to use. Note 'en' is the prefix for
'enum'
// and NOT an abbreviation for 'english'.
$langKey = 'en.' . Inflector::underscore($this->name);
- foreach($this->validate['type']['rule'][1]['default'] as $name) {
+ foreach($this->validate['type']['content']['rule'][1]['default'] as
$name) {
$ret[$name] = _txt($langKey, null, $name);
}
}
@@ -381,13 +381,13 @@
function validEnumsForSelect($field) {
$ret = array();
- if(isset($this->validate[$field]['rule'])
- && $this->validate[$field]['rule'][0] == 'inList'
- && isset($this->validate[$field]['rule'][1])) {
+ if(isset($this->validate[$field]['content']['rule'])
+ && $this->validate[$field]['content']['rule'][0] == 'inList'
+ && isset($this->validate[$field]['content']['rule'][1])) {
// This is the list of valid values for this field. Map these to their
// translated names.
- foreach($this->validate[$field]['rule'][1] as $key) {
+ foreach($this->validate[$field]['content']['rule'][1] as $key) {
$ret[$key] = _txt($this->cm_enum_txt[$field], NULL, $key);
}
}
Modified: registry/trunk/app/Model/CoEnrollmentAttribute.php
===================================================================
--- registry/trunk/app/Model/CoEnrollmentAttribute.php 2013-12-21 23:56:11
UTC (rev 647)
+++ registry/trunk/app/Model/CoEnrollmentAttribute.php 2013-12-23 23:53:23
UTC (rev 648)
@@ -62,6 +62,11 @@
'required' => array(
'rule' => array('range', -2, 2)
),
+ 'required_fields' => array(
+ 'rule' => '/.*/',
+ 'required' => false,
+ 'allowEmpty' => true
+ ),
'ordr' => array(
'rule' => 'numeric',
'required' => false,
@@ -246,9 +251,10 @@
// An attribute is required if the enrollment flow requires it OR if
it is
// type 'o' or 'r' and is required by the data model.
$attr['required'] = $efAttr['CoEnrollmentAttribute']['required'];
+ $attr['mvpa_required'] = false; // does not apply
if(($attrCode == 'o' || $attrCode == 'r')
- && $attrModel->validate[$attrName]['required'])
+ && $attrModel->validate[$attrName]['content']['required'])
$attr['required'] = true;
// Label
@@ -340,8 +346,8 @@
if($attrCode == 'o') {
$attr['validate'] = $attrModel->validate[$attrName];
- if(isset($attr['validate']['rule'][0])
- && $attr['validate']['rule'][0] == 'inList') {
+ if(isset($attr['validate']['content']['rule'][0])
+ && $attr['validate']['content']['rule'][0] == 'inList') {
// If this is a select field, get the set of options
$attr['select'] = $attrModel->validEnumsForSelect($attrName);
}
@@ -358,27 +364,27 @@
$args['joins'][0]['conditions'][0] =
'Cou.co_id=CoEnrollmentFlow.co_id';
$attr['select'] =
$this->CoEnrollmentFlow->CoPetition->Cou->find('list', $args);
- $attr['validate']['rule'][0] = 'inList';
- $attr['validate']['rule'][1] = array_keys($attr['select']);
+ $attr['validate']['content']['rule'][0] = 'inList';
+ $attr['validate']['content']['rule'][1] =
array_keys($attr['select']);
// As of Cake 2.1, inList doesn't work for integers unless you
set strict to false
//
https://cakephp.lighthouseapp.com/projects/42648/tickets/2770-inlist-doesnt-work-more-in-21
- $attr['validate']['rule'][2] = false;
+ $attr['validate']['content']['rule'][2] = false;
} elseif($attrName == 'sponsor_co_person_id') {
// Like COU ID, we need to set up a select
$attr['select'] =
$this->CoEnrollmentFlow->CoPetition->Co->CoPerson->sponsorList($efAttr['CoEnrollmentFlow']['co_id']);
- $attr['validate']['rule'][0] = 'inList';
- $attr['validate']['rule'][1] = array_keys($attr['select']);
+ $attr['validate']['content']['rule'][0] = 'inList';
+ $attr['validate']['content']['rule'][1] =
array_keys($attr['select']);
// As of Cake 2.1, inList doesn't work for integers unless you
set strict to false
//
https://cakephp.lighthouseapp.com/projects/42648/tickets/2770-inlist-doesnt-work-more-in-21
- $attr['validate']['rule'][2] = false;
+ $attr['validate']['content']['rule'][2] = false;
} else {
// Default behavior for all other attributes
$attr['validate'] = $attrModel->validate[$attrName];
- if(isset($attr['validate']['rule'][0])
- && $attr['validate']['rule'][0] == 'inList') {
+ if(isset($attr['validate']['content']['rule'][0])
+ && $attr['validate']['content']['rule'][0] == 'inList') {
// If this is a select field, get the set of options
$attr['select'] = $attrModel->validEnumsForSelect($attrName);
}
@@ -468,15 +474,30 @@
$attr['id'] = $efAttr['CoEnrollmentAttribute']['id'];
$attr['attribute'] =
$efAttr['CoEnrollmentAttribute']['attribute'];
- // Required? We use allowEmpty to check, which is more accurate
than $validate->required.
- // Required is true if the attribute is required by the
enrollment flow configuration,
- // AND of the MVPA's element is also required/allowEmpty (eg:
Email requires mail to be set).
+ // Track if the mvpa itself is required
+ $attr['mvpa_required'] =
$efAttr['CoEnrollmentAttribute']['required'];
- $attr['required'] = ($efAttr['CoEnrollmentAttribute']['required']
- &&
-
isset($attrModel->validate[$k]['allowEmpty'])
- &&
- !$attrModel->validate[$k]['allowEmpty']);
+ // Is this individual attribute required?
+ if(!empty($efAttr['CoEnrollmentAttribute']['required_fields'])) {
+ // See if the field is specified in the fields list. It would
be slightly
+ // more efficient to not split the string for each field each
time through
+ // the foreach loop.
+
+ $rfields = explode(",",
$efAttr['CoEnrollmentAttribute']['required_fields']);
+
+ $attr['required'] = in_array($k, $rfields);
+ } else {
+ // We use allowEmpty to check, which is more accurate than
$validate->required.
+ // Required is true if the attribute is required by the
enrollment flow configuration,
+ // AND if the MVPA's element is also required/allowEmpty (eg:
Email requires mail to be set).
+
+ $attr['required'] = ($attr['mvpa_required']
+ &&
+ // XXX need to look for other places where ['content'] needs to be added
+
isset($attrModel->validate[$k]['content']['allowEmpty'])
+ &&
+
!$attrModel->validate[$k]['content']['allowEmpty']);
+ }
// Org attributes can ignore authoritative values
$attr['ignore_authoritative'] =
@@ -547,8 +568,8 @@
$attr['validate'] = $attrModel->validate[$k];
if($k != 'type'
- && isset($attr['validate']['rule'][0])
- && $attr['validate']['rule'][0] == 'inList') {
+ && isset($attr['validate']['content']['rule'][0])
+ && $attr['validate']['content']['rule'][0] == 'inList') {
// If this is a select field, get the set of options
$attr['select'] = $attrModel->validEnumsForSelect($attrName);
}
@@ -564,6 +585,7 @@
$attr['id'] = $efAttr['CoEnrollmentAttribute']['id'];
$attr['attribute'] = $efAttr['CoEnrollmentAttribute']['attribute'];
$attr['required'] = $efAttr['CoEnrollmentAttribute']['required'];
+ $attr['mvpa_required'] = false; // does not apply
$attr['hidden'] = false;
$attr['label'] = $efAttr['CoEnrollmentAttribute']['label'];
$attr['description'] =
$efAttr['CoEnrollmentAttribute']['description'];
@@ -573,7 +595,7 @@
$attr['default'] =
$efAttr['CoEnrollmentAttributeDefault'][0]['value'];
}
$attr['modifiable'] =
$efAttr['CoEnrollmentAttributeDefault'][0]['modifiable'];
- $attr['validate']['rule'][0] = 'inList';
+ $attr['validate']['content']['rule'][0] = 'inList';
// Pull the set of groups for the select
$args = array();
Modified: registry/trunk/app/Model/CoGroupMember.php
===================================================================
--- registry/trunk/app/Model/CoGroupMember.php 2013-12-21 23:56:11 UTC (rev
647)
+++ registry/trunk/app/Model/CoGroupMember.php 2013-12-23 23:53:23 UTC (rev
648)
@@ -52,14 +52,20 @@
// Validation rules for table elements
public $validate = array(
'co_person_id' => array(
- 'rule' => 'numeric',
- 'required' => true
+ 'content' => array(
+ 'rule' => 'numeric',
+ 'required' => true
+ )
),
'member' => array(
- 'rule' => array('boolean')
+ 'content' => array(
+ 'rule' => array('boolean')
+ )
),
'owner' => array(
- 'rule' => array('boolean')
+ 'content' => array(
+ 'rule' => array('boolean')
+ )
)
);
Modified: registry/trunk/app/Model/CoPerson.php
===================================================================
--- registry/trunk/app/Model/CoPerson.php 2013-12-21 23:56:11 UTC (rev
647)
+++ registry/trunk/app/Model/CoPerson.php 2013-12-23 23:53:23 UTC (rev
648)
@@ -101,30 +101,37 @@
// public $order = array("CoPerson.id");
// Validation rules for table elements
+ // Validation rules must be named 'content' for petition dynamic rule
adjustment
public $validate = array(
'co_id' => array(
- 'rule' => 'numeric',
- 'required' => true,
- 'message' => 'A CO ID must be provided'
+ 'content' => array(
+ 'rule' => 'numeric',
+ 'required' => true,
+ 'message' => 'A CO ID must be provided'
+ )
),
'primary_name_id' => array(
- 'rule' => 'numeric',
- 'required' => false,
- 'allowEmpty' => true
+ 'content' => array(
+ 'rule' => 'numeric',
+ 'required' => false,
+ 'allowEmpty' => true
+ )
),
'status' => array(
- 'rule' => array('inList', array(StatusEnum::Active,
- StatusEnum::Approved,
- StatusEnum::Declined,
- StatusEnum::Deleted,
- StatusEnum::Denied,
- StatusEnum::Invited,
- StatusEnum::Pending,
- StatusEnum::PendingApproval,
- StatusEnum::PendingConfirmation,
- StatusEnum::Suspended)),
- 'required' => true,
- 'message' => 'A valid status must be selected'
+ 'content' => array(
+ 'rule' => array('inList', array(StatusEnum::Active,
+ StatusEnum::Approved,
+ StatusEnum::Declined,
+ StatusEnum::Deleted,
+ StatusEnum::Denied,
+ StatusEnum::Invited,
+ StatusEnum::Pending,
+ StatusEnum::PendingApproval,
+ StatusEnum::PendingConfirmation,
+ StatusEnum::Suspended)),
+ 'required' => true,
+ 'message' => 'A valid status must be selected'
+ )
)
);
Modified: registry/trunk/app/Model/CoPersonRole.php
===================================================================
--- registry/trunk/app/Model/CoPersonRole.php 2013-12-21 23:56:11 UTC (rev
647)
+++ registry/trunk/app/Model/CoPersonRole.php 2013-12-23 23:53:23 UTC (rev
648)
@@ -68,69 +68,91 @@
// public $order = array("CoPersonRole.id");
// Validation rules for table elements
+ // Validation rules must be named 'content' for petition dynamic rule
adjustment
public $validate = array(
'co_person_id' => array(
- 'rule' => array('numeric'),
- 'required' => true,
- 'message' => 'A CO Person ID must be provided'
+ 'content' => array(
+ 'rule' => array('numeric'),
+ 'required' => true,
+ 'message' => 'A CO Person ID must be provided'
+ )
),
'cou_id' => array(
- 'rule' => array('numeric'),
- 'required' => false,
- 'allowEmpty' => true
+ 'content' => array(
+ 'rule' => array('numeric'),
+ 'required' => false,
+ 'allowEmpty' => true
+ )
),
'title' => array(
- 'rule' => array('maxLength', 128),
- 'required' => false,
- 'allowEmpty' => true
+ 'content' => array(
+ 'rule' => array('maxLength', 128),
+ 'required' => false,
+ 'allowEmpty' => true
+ )
),
'o' => array(
- 'rule' => array('maxLength', 128),
- 'required' => false,
- 'allowEmpty' => true
+ 'content' => array(
+ 'rule' => array('maxLength', 128),
+ 'required' => false,
+ 'allowEmpty' => true
+ )
),
'ou' => array(
- 'rule' => array('maxLength', 128),
- 'required' => false,
- 'allowEmpty' => true
+ 'content' => array(
+ 'rule' => array('maxLength', 128),
+ 'required' => false,
+ 'allowEmpty' => true
+ )
),
'valid_from' => array(
- 'rule' => array('validateTimestamp'),
- 'required' => false,
- 'allowEmpty' => true
+ 'content' => array(
+ 'rule' => array('validateTimestamp'),
+ 'required' => false,
+ 'allowEmpty' => true
+ )
),
'valid_through' => array(
- 'rule' => array('validateTimestamp'),
- 'required' => false,
- 'allowEmpty' => true
+ 'content' => array(
+ 'rule' => array('validateTimestamp'),
+ 'required' => false,
+ 'allowEmpty' => true
+ )
),
'status' => array(
- 'rule' => array('inList', array(StatusEnum::Active,
- StatusEnum::Approved,
- StatusEnum::Declined,
- StatusEnum::Deleted,
- StatusEnum::Denied,
- StatusEnum::Invited,
- StatusEnum::Pending,
- StatusEnum::PendingApproval,
- StatusEnum::PendingConfirmation,
- StatusEnum::Suspended))
+ 'content' => array(
+ 'rule' => array('inList', array(StatusEnum::Active,
+ StatusEnum::Approved,
+ StatusEnum::Declined,
+ StatusEnum::Deleted,
+ StatusEnum::Denied,
+ StatusEnum::Invited,
+ StatusEnum::Pending,
+ StatusEnum::PendingApproval,
+ StatusEnum::PendingConfirmation,
+ StatusEnum::Suspended))
+ )
),
'sponsor_co_person_id' => array(
- 'rule' => array('numeric'),
- 'required' => false,
- 'allowEmpty' => true
+ 'content' => array(
+ 'rule' => array('numeric'),
+ 'required' => false,
+ 'allowEmpty' => true
+ )
),
'affiliation' => array(
- 'rule' => array('inList', array(AffiliationEnum::Faculty,
- AffiliationEnum::Student,
- AffiliationEnum::Staff,
- AffiliationEnum::Alum,
- AffiliationEnum::Member,
- AffiliationEnum::Affiliate,
- AffiliationEnum::Employee,
- AffiliationEnum::LibraryWalkIn)),
- 'required' => true
+ 'content' => array(
+ 'rule' => array('inList', array(AffiliationEnum::Faculty,
+ AffiliationEnum::Student,
+ AffiliationEnum::Staff,
+ AffiliationEnum::Alum,
+ AffiliationEnum::Member,
+ AffiliationEnum::Affiliate,
+ AffiliationEnum::Employee,
+ AffiliationEnum::LibraryWalkIn)),
+ 'required' => true,
+ 'allowEmpty' => false
+ )
)
);
Modified: registry/trunk/app/Model/CoPetition.php
===================================================================
--- registry/trunk/app/Model/CoPetition.php 2013-12-21 23:56:11 UTC (rev
647)
+++ registry/trunk/app/Model/CoPetition.php 2013-12-23 23:53:23 UTC (rev
648)
@@ -159,8 +159,6 @@
*/
public function adjustValidationRules($model, $efAttrs) {
- // XXX With Cake 2.2 we can use dynamic validation rules instead of
mucking around this way (CO-353)
-
foreach($efAttrs as $efAttr) {
// The model might be something like EnrolleeCoPersonRole or
EnrolleeCoPersonRole.Name
// or EnrolleeCoPersonRole.TelephoneNumber.0. However, since we only
adjust validation
@@ -170,10 +168,18 @@
if(count($m) == 1) {
if($m[0] == $model) {
- $this->$model->validate[ $efAttr['field'] ] = $efAttr['validate'];
+ $xfield = $this->$model->validator()->getField($efAttr['field']);
- $this->$model->validate[ $efAttr['field'] ]['required'] =
$efAttr['required'];
- $this->$model->validate[ $efAttr['field'] ]['allowEmpty'] =
!$efAttr['required'];
+ if($xfield && $xfield->getRule('content')) {
+ $xreq = (isset($efAttr['required']) && $efAttr['required']);
+
+ $xfield->getRule('content')->required = $xreq;
+ $xfield->getRule('content')->allowEmpty = !$xreq;
+
+ if($xreq) {
+ $xfield->getRule('content')->message = _txt('er.field.req');
+ }
+ }
}
}
}
@@ -223,6 +229,12 @@
return false;
}
+ if($efAttr['mvpa_required']) {
+ // This attribute is part of an MVPA that is required, so stop
+
+ return false;
+ }
+
if(isset($data[ $efAttr['field'] ]) &&
$data[ $efAttr['field'] ] != "") {
// Field is set, so stop
@@ -231,6 +243,8 @@
}
}
+ debug("true");
+
return true;
}
@@ -511,8 +525,6 @@
// Dynamically adjust validation rules according to the enrollment flow
- // XXX If we didn't generate a CO Person ID above for some reason,
that validation will fail
- // here. With dynamic validation rules in Cake 2.2 we could drop that
rule. (CO-353)
$this->adjustValidationRules('EnrolleeCoPersonRole', $efAttrs);
// Manually validate CoPersonRole
@@ -1578,6 +1590,26 @@
$this->$primaryModel->$model->set($data);
+ foreach($efAttrs as $efAttr) {
+ if($efAttr['id'] == $instance) {
+
+ // Make sure the validation rule matches the required status
of this attribute
+ $xfield =
$this->$primaryModel->$model->validator()->getField($efAttr['field']);
+
+ if($xfield) {
+ $xreq = (isset($efAttr['required']) &&
$efAttr['required']);
+
+ $xfield->getRule('content')->required = $xreq;
+ $xfield->getRule('content')->allowEmpty = !$xreq;
+
+ if($xreq) {
+ $xfield->getRule('content')->message =
_txt('er.field.req');
+ }
+ }
+ // else not a relevant field (eg: co_enrollment_attribute_id)
+ }
+ }
+
// Make sure to use invalidFields(), which won't try to validate
(possibly
// missing) related models.
$errFields = $this->$primaryModel->$model->invalidFields();
@@ -1638,10 +1670,17 @@
// Extended attributes generally won't have validate by Cake set
since their models are
// dynamically bound, so grabbing validation rules from $efAttr is
a win.
- $this->$primaryModel->$m[1]->validate[ $efAttr['field'] ] =
$efAttr['validate'];
- $this->$primaryModel->$m[1]->validate[ $efAttr['field']
]['required'] = $efAttr['required'];
- $this->$primaryModel->$m[1]->validate[ $efAttr['field']
]['allowEmpty'] = !$efAttr['required'];
+ $vrule = $efAttr['validate'];
+ $vreq = (isset($efAttr['required']) && $efAttr['required']);
+ $vrule['required'] = $vreq;
+ $vrule['allowEmpty'] = !$vreq;
+ $vrule['message'] = _txt('er.field.req');
+
+ $this->$primaryModel->$m[1]->validator()->add($efAttr['field'],
+ 'content',
+ $vrule);
+
// Make sure validation only sees this model's data
$data = array();
$data[$model] = $relatedModels['extended'][$model];
Modified: registry/trunk/app/Model/EmailAddress.php
===================================================================
--- registry/trunk/app/Model/EmailAddress.php 2013-12-21 23:56:11 UTC (rev
647)
+++ registry/trunk/app/Model/EmailAddress.php 2013-12-23 23:53:23 UTC (rev
648)
@@ -47,34 +47,45 @@
public $order = array("mail");
// Validation rules for table elements
+ // Validation rules must be named 'content' for petition dynamic rule
adjustment
public $validate = array(
// Don't require mail or type since $belongsTo saves won't validate if
they're empty
'mail' => array(
- 'rule' => array('email'),
- 'required' => false,
- 'allowEmpty' => false,
- 'message' => 'Please enter a valid email address'
+ 'content' => array(
+ 'rule' => array('email'),
+ 'required' => false,
+ 'allowEmpty' => false,
+ 'message' => 'Please enter a valid email address'
+ )
),
'type' => array(
- 'rule' => array('inList', array(EmailAddressEnum::Delivery,
- EmailAddressEnum::Forwarding,
- EmailAddressEnum::Official,
- EmailAddressEnum::Personal)),
- 'required' => false,
- 'allowEmpty' => false
+ 'content' => array(
+ 'rule' => array('inList', array(EmailAddressEnum::Delivery,
+ EmailAddressEnum::Forwarding,
+ EmailAddressEnum::Official,
+ EmailAddressEnum::Personal)),
+ 'required' => false,
+ 'allowEmpty' => false
+ )
),
'verified' => array(
- 'rule' => array('boolean')
+ 'content' => array(
+ 'rule' => array('boolean')
+ )
),
'co_person_id' => array(
- 'rule' => 'numeric',
- 'required' => false,
- 'allowEmpty' => true
+ 'content' => array(
+ 'rule' => 'numeric',
+ 'required' => false,
+ 'allowEmpty' => true
+ )
),
'org_identity_id' => array(
- 'rule' => 'numeric',
- 'required' => false,
- 'allowEmpty' => true
+ 'content' => array(
+ 'rule' => 'numeric',
+ 'required' => false,
+ 'allowEmpty' => true
+ )
)
);
Modified: registry/trunk/app/Model/Identifier.php
===================================================================
--- registry/trunk/app/Model/Identifier.php 2013-12-21 23:56:11 UTC (rev
647)
+++ registry/trunk/app/Model/Identifier.php 2013-12-23 23:53:23 UTC (rev
648)
@@ -46,44 +46,57 @@
public $actsAs = array('Containable', 'Provisioner');
// Validation rules for table elements
+ // Validation rules must be named 'content' for petition dynamic rule
adjustment
public $validate = array(
// Don't require any element since $belongsTo saves won't validate if
they're empty
'identifier' => array(
- 'rule' => array('maxLength', 256),
- 'required' => false,
- 'allowEmpty' => false
+ 'content' => array(
+ 'rule' => array('maxLength', 256),
+ 'required' => false,
+ 'allowEmpty' => false
+ )
),
'type' => array(
- 'rule' => array('validateExtendedType',
- array('attribute' => 'Identifier',
- 'default' => array(IdentifierEnum::ePPN,
- IdentifierEnum::ePTID,
- IdentifierEnum::Mail,
- IdentifierEnum::OpenID,
- IdentifierEnum::UID))),
- 'required' => false,
- 'allowEmpty' => false
+ 'content' => array(
+ 'rule' => array('validateExtendedType',
+ array('attribute' => 'Identifier',
+ 'default' => array(IdentifierEnum::ePPN,
+ IdentifierEnum::ePTID,
+ IdentifierEnum::Mail,
+ IdentifierEnum::OpenID,
+ IdentifierEnum::UID))),
+ 'required' => false,
+ 'allowEmpty' => false
+ )
),
'login' => array(
- 'rule' => array('boolean'),
- 'required' => false,
- 'allowEmpty' => true
+ 'content' => array(
+ 'rule' => array('boolean'),
+ 'required' => false,
+ 'allowEmpty' => true
+ )
),
'status' => array(
- 'rule' => array('inList', array(StatusEnum::Active,
- StatusEnum::Deleted)),
- 'required' => true,
- 'allowEmpty' => false
+ 'content' => array(
+ 'rule' => array('inList', array(StatusEnum::Active,
+ StatusEnum::Deleted)),
+ 'required' => true,
+ 'allowEmpty' => false
+ )
),
'co_person_id' => array(
- 'rule' => 'numeric',
- 'required' => false,
- 'allowEmpty' => true
+ 'content' => array(
+ 'rule' => 'numeric',
+ 'required' => false,
+ 'allowEmpty' => true
+ )
),
'org_identity_id' => array(
- 'rule' => 'numeric',
- 'required' => false,
- 'allowEmpty' => true
+ 'content' => array(
+ 'rule' => 'numeric',
+ 'required' => false,
+ 'allowEmpty' => true
+ )
)
);
Modified: registry/trunk/app/Model/Name.php
===================================================================
--- registry/trunk/app/Model/Name.php 2013-12-21 23:56:11 UTC (rev 647)
+++ registry/trunk/app/Model/Name.php 2013-12-23 23:53:23 UTC (rev 648)
@@ -50,61 +50,82 @@
);
// Validation rules for table elements
+ // Validation rules must be named 'content' for petition dynamic rule
adjustment
public $validate = array(
'honorific' => array(
- 'rule' => array('maxLength', 32),
- 'required' => false,
- 'allowEmpty' => true
+ 'content' => array(
+ 'rule' => array('maxLength', 32),
+ 'required' => false,
+ 'allowEmpty' => true
+ )
),
'given' => array(
- 'rule' => array('maxLength', 128),
- 'required' => true,
- 'allowEmpty' => false,
- 'message' => 'A given name must be provided'
+ 'content' => array(
+ 'rule' => array('maxLength', 128),
+ 'required' => true,
+ 'allowEmpty' => false,
+ 'message' => 'A given name must be provided'
+ )
),
'middle' => array(
- 'rule' => array('maxLength', 128),
- 'required' => false,
- 'allowEmpty' => true
+ 'content' => array(
+ 'rule' => array('maxLength', 128),
+ 'required' => false,
+ 'allowEmpty' => true
+ )
),
'family' => array(
- 'rule' => array('maxLength', 128),
- 'required' => false,
- 'allowEmpty' => true
+ 'content' => array(
+ 'rule' => array('maxLength', 128),
+ 'required' => false,
+ 'allowEmpty' => true
+ )
),
'suffix' => array(
- 'rule' => array('maxLength', 32),
- 'required' => false,
- 'allowEmpty' => true
+ 'content' => array(
+ 'rule' => array('maxLength', 32),
+ 'required' => false,
+ 'allowEmpty' => true
+ )
),
'type' => array(
- 'rule' => array('inList', array(NameEnum::Alternate,
- NameEnum::Author,
- NameEnum::FKA,
- NameEnum::Official,
- NameEnum::Preferred)),
- 'required' => true,
- 'allowEmpty' => false
+ 'content' => array(
+ 'rule' => array('inList', array(NameEnum::Alternate,
+ NameEnum::Author,
+ NameEnum::FKA,
+ NameEnum::Official,
+ NameEnum::Preferred)),
+ 'required' => true,
+ 'allowEmpty' => false
+ )
),
'language' => array(
- 'rule' => array('validateLanguage'),
- 'required' => false,
- 'allowEmpty' => true
+ 'content' => array(
+ 'rule' => array('validateLanguage'),
+ 'required' => false,
+ 'allowEmpty' => true
+ )
),
'primary_name' => array(
- 'rule' => array('boolean'),
- 'required' => false,
- 'allowEmpty' => true
+ 'content' => array(
+ 'rule' => array('boolean'),
+ 'required' => false,
+ 'allowEmpty' => true
+ )
),
'co_person_id' => array(
- 'rule' => 'numeric',
- 'required' => false,
- 'allowEmpty' => true
+ 'content' => array(
+ 'rule' => 'numeric',
+ 'required' => false,
+ 'allowEmpty' => true
+ )
),
'org_identity_id' => array(
- 'rule' => 'numeric',
- 'required' => false,
- 'allowEmpty' => true
+ 'content' => array(
+ 'rule' => 'numeric',
+ 'required' => false,
+ 'allowEmpty' => true
+ )
)
);
Modified: registry/trunk/app/Model/OrgIdentity.php
===================================================================
--- registry/trunk/app/Model/OrgIdentity.php 2013-12-21 23:56:11 UTC (rev
647)
+++ registry/trunk/app/Model/OrgIdentity.php 2013-12-23 23:53:23 UTC (rev
648)
@@ -80,49 +80,64 @@
// public $order = array("Name.family", "Name.given");
// Validation rules for table elements
+ // Validation rules must be named 'content' for petition dynamic rule
adjustment
public $validate = array(
'affiliation' => array(
- 'rule' => array('inList', array(AffiliationEnum::Faculty,
- AffiliationEnum::Student,
- AffiliationEnum::Staff,
- AffiliationEnum::Alum,
- AffiliationEnum::Member,
- AffiliationEnum::Affiliate,
- AffiliationEnum::Employee,
- AffiliationEnum::LibraryWalkIn)),
- 'required' => false,
- 'allowEmpty' => true
+ 'content' => array(
+ 'rule' => array('inList', array(AffiliationEnum::Faculty,
+ AffiliationEnum::Student,
+ AffiliationEnum::Staff,
+ AffiliationEnum::Alum,
+ AffiliationEnum::Member,
+ AffiliationEnum::Affiliate,
+ AffiliationEnum::Employee,
+ AffiliationEnum::LibraryWalkIn)),
+ 'required' => false,
+ 'allowEmpty' => true
+ )
),
'co_id' => array(
- 'rule' => 'numeric',
- 'required' => false,
- 'allowEmpty' => true
+ 'content' => array(
+ 'rule' => 'numeric',
+ 'required' => false,
+ 'allowEmpty' => true
+ )
),
'o' => array(
- 'rule' => '/.*/',
- 'required' => false,
- 'allowEmpty' => true
+ 'content' => array(
+ 'rule' => '/.*/',
+ 'required' => false,
+ 'allowEmpty' => true
+ )
),
'organization_id' => array(
- 'rule' => 'numeric',
- 'required' => false,
- 'allowEmpty' => true
+ 'content' => array(
+ 'rule' => 'numeric',
+ 'required' => false,
+ 'allowEmpty' => true
+ )
),
'ou' => array(
- 'rule' => '/.*/',
- 'required' => false,
- 'allowEmpty' => true
+ 'content' => array(
+ 'rule' => '/.*/',
+ 'required' => false,
+ 'allowEmpty' => true
+ )
),
'primary_name_id' => array(
- 'rule' => 'numeric',
- 'required' => false,
- 'allowEmpty' => true
+ 'content' => array(
+ 'rule' => 'numeric',
+ 'required' => false,
+ 'allowEmpty' => true
+ )
),
'title' => array(
- 'rule' => '/.*/',
- 'required' => false,
- 'allowEmpty' => true
- ),
+ 'content' => array(
+ 'rule' => '/.*/',
+ 'required' => false,
+ 'allowEmpty' => true
+ )
+ )
);
// Enum type hints
Modified: registry/trunk/app/Model/TelephoneNumber.php
===================================================================
--- registry/trunk/app/Model/TelephoneNumber.php 2013-12-21 23:56:11
UTC (rev 647)
+++ registry/trunk/app/Model/TelephoneNumber.php 2013-12-23 23:53:23
UTC (rev 648)
@@ -47,28 +47,39 @@
public $order = array("number");
// Validation rules for table elements
+ // Validation rules must be named 'content' for petition dynamic rule
adjustment
public $validate = array(
// Don't require number or type since $belongsTo saves won't validate if
they're empty
'number' => array(
- 'rule' => array('maxLength', 64), // cake has telephone number
validation, but US only
- 'required' => false, // We allow any chars to cover
things like "ext 2009"
- 'allowEmpty' => false
+ 'content' => array(
+ 'rule' => array('maxLength', 64), // cake has telephone number
validation, but US only
+ 'required' => false, // We allow any chars to cover
things like "ext 2009"
+ 'allowEmpty' => false
+ )
),
'type' => array(
- 'rule' => array('inList', array(ContactEnum::Fax,
- ContactEnum::Home,
- ContactEnum::Mobile,
- ContactEnum::Office)),
- 'required' => false,
- 'allowEmpty' => true
+ 'content' => array(
+ 'rule' => array('inList', array(ContactEnum::Fax,
+ ContactEnum::Home,
+ ContactEnum::Mobile,
+ ContactEnum::Office)),
+ 'required' => false,
+ 'allowEmpty' => true
+ )
),
'co_person_role_id' => array(
- 'rule' => 'numeric',
- 'required' => false
+ 'content' => array(
+ 'rule' => 'numeric',
+ 'required' => false,
+ 'allowEmpty' => false
+ )
),
'org_identity_id' => array(
- 'rule' => 'numeric',
- 'required' => false
+ 'content' => array(
+ 'rule' => 'numeric',
+ 'required' => false,
+ 'allowEmpty' => false
+ )
)
);
Modified: registry/trunk/app/View/CoEnrollmentAttributes/fields.inc
===================================================================
--- registry/trunk/app/View/CoEnrollmentAttributes/fields.inc 2013-12-21
23:56:11 UTC (rev 647)
+++ registry/trunk/app/View/CoEnrollmentAttributes/fields.inc 2013-12-23
23:53:23 UTC (rev 648)
@@ -141,16 +141,59 @@
}
function toggle_attr_type_div() {
+ // Show or hide language selectors and required fields selectors
+
var curattr =
document.getElementById('CoEnrollmentAttributeAttribute').value;
var curattrarr = curattr.split(":");
var curattrcode = curattrarr[0];
var curattrname = curattrarr[1];
- if(curattrname == "address" || curattrname == "name") {
+ // Current required fields
+ var curreqfields =
document.getElementById('CoEnrollmentAttributeRequiredFields').value;
+
+ if(curattrname == "address") {
$("#type_div").show("fade");
+ $("#address_required_fields_div").show("fade");
+ $("#name_required_fields_div").hide("fade");
+
+ // Synchronize the popup and the actual field that holds the value
+
+ if(curreqfields == "") {
+ // No current value, set field to default
+
document.getElementById('CoEnrollmentAttributeAddressFields').options[0].selected
= true;
+ document.getElementById('CoEnrollmentAttributeRequiredFields').value
+ =
document.getElementById('CoEnrollmentAttributeAddressFields').value;
+ } else {
+ // Set popup to current field value
+ document.getElementById('CoEnrollmentAttributeAddressFields').value
= curreqfields;
+ }
+ } else if(curattrname == "name") {
+ $("#type_div").show("fade");
+ $("#address_required_fields_div").hide("fade");
+ $("#name_required_fields_div").show("fade");
+ // Make sure the popup matches the current required_fields value
+ document.getElementById('CoEnrollmentAttributeNameFields').value=
+ document.getElementById('CoEnrollmentAttributeRequiredFields').value
+
+ // Synchronize the popup and the actual field that holds the value
+
+ if(curreqfields == "") {
+ // No current value, set field to default
+
document.getElementById('CoEnrollmentAttributeNameFields').options[0].selected
= true;
+ document.getElementById('CoEnrollmentAttributeRequiredFields').value
+ = document.getElementById('CoEnrollmentAttributeNameFields').value;
+ } else {
+ // Set popup to current field value
+ document.getElementById('CoEnrollmentAttributeNameFields').value =
curreqfields;
+ }
} else {
$("#type_div").hide("fade");
+ $("#address_required_fields_div").hide("fade");
+ $("#name_required_fields_div").hide("fade");
+
+ // Blank the current required fields
+ document.getElementById('CoEnrollmentAttributeRequiredFields').value =
"";
}
}
@@ -223,7 +266,8 @@
?
$co_enrollment_attributes[0]['CoEnrollmentAttribute']['attribute']
: null);
$attrs['empty'] = false;
- $attrs['onchange'] =
"toggle_attr_def_div();toggle_copy_to_coperson_div();toggle_attr_type_div();";
+ $attrs['onchange'] =
"document.getElementById('CoEnrollmentAttributeRequiredFields').value='';
+
toggle_attr_def_div();toggle_copy_to_coperson_div();toggle_attr_type_div();";
if($e) {
print $this->Form->select('attribute',
@@ -256,11 +300,55 @@
}
?>
</div>
+ <div id="address_required_fields_div" style="display: none">
+ <?php print _txt('fd.address.fields.req'); ?><br />
+ <select
+ id="CoEnrollmentAttributeAddressFields"
+
onchange="javascript:document.getElementById('CoEnrollmentAttributeRequiredFields').value=this.value">
+ <option value="line1"><?php
+ print _txt('fd.address.line1') . " (" . _txt('fd.default') .
")";
+ ?></option>
+ <option value="line1,locality,state,postal_code"><?php
+ print _txt('fd.address.line1') . ", "
+ . _txt('fd.address.locality') . ", "
+ . _txt('fd.address.state') . ", "
+ . _txt('fd.address.postal_code');
+ ?></option>
+ <option value="line1,locality,state,postal_code,country"><?php
+ print _txt('fd.address.line1') . ", "
+ . _txt('fd.address.locality') . ", "
+ . _txt('fd.address.state') . ", "
+ . _txt('fd.address.postal_code') . ", "
+ . _txt('fd.address.country');
+ ?></option>
+ </select>
+ </div>
+ <div id="name_required_fields_div" style="display: none">
+ <?php print _txt('fd.name.fields.req'); ?><br />
+ <select
+ id="CoEnrollmentAttributeNameFields"
+
onchange="javascript:document.getElementById('CoEnrollmentAttributeRequiredFields').value=this.value">
+ <option value="given"><?php
+ print _txt('fd.name.given') . " (" . _txt('fd.default') . ")";
+ ?></option>
+ <option value="given,family"><?php
+ print _txt('fd.name.given') . ", "
+ . _txt('fd.name.family');
+ ?></option>
+ </select>
+ </div>
+ <div id="required_fields_div" style="display: none">
+ <?php
+ if($e) {
+ print $this->Form->input('required_fields');
+ }
+ ?>
+ </div>
<div id="copy_to_coperson_div" style="display: none">
<?php print ($e
? $this->Form->input('copy_to_coperson',
array('default' => false))
- :
($co_enrollment_attributes[0]['CoEnrollmentAttribute'][0]['copy_to_coperson']
+ :
($co_enrollment_attributes[0]['CoEnrollmentAttribute']['copy_to_coperson']
? _txt('fd.yes') : _txt('fd.no')));
print _txt('fd.ea.attr.copy2cop');
?>
Modified: registry/trunk/app/View/CoPetitions/petition-attributes.inc
===================================================================
--- registry/trunk/app/View/CoPetitions/petition-attributes.inc 2013-12-21
23:56:11 UTC (rev 647)
+++ registry/trunk/app/View/CoPetitions/petition-attributes.inc 2013-12-23
23:53:23 UTC (rev 648)
@@ -167,7 +167,7 @@
// Sort attributes by model for printing
$coea_model = array();
$misc_attr = array();
-
+
foreach ($co_enrollment_attributes as $ea){
if ($ea['hidden']) { // Sort hidden ones out
$hidden_attr[] = $ea;
@@ -180,43 +180,55 @@
}
}
}
-
+
// Print the hidden fields
foreach ($hidden_attr as $ea) {
- if($ea['hidden'])
+ if($ea['hidden']) {
$fieldName = $ea['model'] . '.' . $ea['field'];
-
+ }
+
print $this->Form->hidden($fieldName, array('default' =>
$ea['default'])) . "\n";
}
-
+
// Print the ones not hidden
- foreach ($coea_model as $m => $coe_attributes):
+ foreach ($coea_model as $m => $coe_attributes):
+
+ $mvpa = (count($coe_attributes) > 1);
?>
<div class="ui-widget modelbox">
<div class = "boxtitle">
<b><?php print $m ?></b>
<?php
+ // Is the MVPA required? We'll just check the first attribute
since they
+ // should all be the same.
+ if($mvpa && $coe_attributes[0]['mvpa_required']) {
+ print "<font class=\"required\">*</font>\n";
+ }
+
// Only print the description once if it's the same for all items
$groupDesc = false; // Not grouping by default
$descriptions = array();
-
+
foreach($coe_attributes as $ea) {
$descriptions[] = $ea['description'];
}
$descTypeCount = count(array_count_values($descriptions));
-
+
if($descTypeCount == 1 &&
!empty($coe_attributes[0]['description'])) {
print "</br>\n<font class=\"desc\">" . $ea['description'] .
"</font>\n";
$groupDesc = true; // Set flag for later
}
+
+ if($mvpa && !$coe_attributes[0]['mvpa_required']) {
+ print "<br /><font class=\"required\">" . _txt('fd.pt.required')
. "</font>\n";
+ }
?>
-
</div>
<table id="<?php print $this->action; ?>_co_petition_attrs_<?php print
$m?>" class="ui-widget">
<tbody>
<?php
$l = 0; // Reset zebra stripes for each box
- foreach ($coe_attributes as $ea):
+ foreach ($coe_attributes as $ea):
if(!$ea['hidden'] && isset($ea['default']) &&
!$ea['modifiable']) {
// Since disabled values don't submit with the form, convert
them to hidden
// fields and change the fieldName for the visible attribute
@@ -229,7 +241,7 @@
$fieldName = $ea['model'] . '.' . $ea['field'];
}
?>
-
+
<tr class="line<?php print ($l % 2); $l++; ?>">
<td>
<?php
@@ -237,7 +249,11 @@
print "<b>" . $ea['label'] . "</b>";
if($ea['required']) {
- print "<font class=\"required\">*</font>\n";
+ if($mvpa && !$ea['mvpa_required']) {
+ print "<font class=\"required\">†</font>\n";
+ } else {
+ print "<font class=\"required\">*</font>\n";
+ }
}
if(isset($ea['description'])
@@ -254,8 +270,9 @@
// The type of validation rule can influence what we
output.
$ruleType = 'default';
- if(isset($ea['validate']['rule'][0]))
- $ruleType = $ea['validate']['rule'][0];
+ if(isset($ea['validate']['content']['rule'][0])) {
+ $ruleType = $ea['validate']['content']['rule'][0];
+ }
// XXX need to retrieve current values for edit and view
@@ -306,7 +323,17 @@
// Use default field
$args = array();
- $args['required'] = $ea['required'];
+ // An attribute is required if (1) it is part of an
MVPA that is required
+ // and the field itself is required, or (2) it is not
part of an MVPA and
+ // the field itself is required
+ $args['required'] = false;
+ if(isset($ea['mvpa_required'])) {
+ if($ea['mvpa_required']) {
+ $args['required'] = $ea['required'];
+ }
+ } else {
+ $args['required'] = $ea['required'];
+ }
// Use a provided default value, if one specified
if(isset($ea['default'])) {
- [comanage-dev] r648 - in registry/trunk/app: Config/Schema Controller Lib Model View/CoEnrollmentAttributes View/CoPetitions, svnlog, 12/23/2013
Archive powered by MHonArc 2.6.16.