Index: site/App/SideBlock/Admin/Form/Abstract.php =================================================================== --- site/App/SideBlock/Admin/Form/Abstract.php (revision 5616) +++ site/App/SideBlock/Admin/Form/Abstract.php (working copy) @@ -268,7 +268,7 @@ if (!Qs_SiteMap::findFirst(null, array('type' => 'Form_Newsletter_Admin_'), null, 'url')) { unset($types[App_SideBlock_Obj::TYPE_SUBSCRIPTION]); } - if (!Qs_SiteMap::findFirst(null, array('type' => 'App_ECommerce_Product_'), null, 'url')) { + if (!Qs_SiteMap::findFirst(null, array('type' => 'ECommerce_Product_'), null, 'url')) { unset($types[App_SideBlock_Obj::TYPE_FEATURED_PRODUCTS]); } if (!Qs_SiteMap::findFirst(null, array('type' => 'Event\\'), null, 'url')) { Index: site/App/SideBlock/Admin/Form/config.php =================================================================== --- site/App/SideBlock/Admin/Form/config.php (revision 5616) +++ site/App/SideBlock/Admin/Form/config.php (working copy) @@ -11,16 +11,23 @@ 'event' => 'change', 'rules' => [ [ - 'value' => Obj::TYPE_CONTACT_FORM, - '_elements' => ['pageType', 'linkType'] - ], [ 'value' => Obj::TYPE_HTML, '_elements' => ['content', 'pageType', 'linkType'] ], [ 'value' => Obj::TYPE_SITEMAP, '_elements' => ['pageType', 'pageId', 'linkType'] ], [ - 'value' => Obj::TYPE_TESTIMONIAL, + 'value' => [ + Obj::TYPE_TESTIMONIAL, + Obj::TYPE_SUBSCRIPTION, + Obj::TYPE_RECENT_NEWS, + Obj::TYPE_NEWSLETTERS, + Obj::TYPE_FEATURED_NEWS, + Obj::TYPE_FEATURED_POSTS, + Obj::TYPE_FEATURED_PRODUCTS, + Obj::TYPE_UPCOMING_EVENTS, + Obj::TYPE_CONTACT_FORM, + ], '_elements' => ['pageType', 'linkType'] ] ] Index: site/Qs/Form/DynamicFormTrait.php =================================================================== --- site/Qs/Form/DynamicFormTrait.php (revision 5616) +++ site/Qs/Form/DynamicFormTrait.php (working copy) @@ -65,14 +65,12 @@ $unavailable = array(); foreach ($relation['rules'] as $rule) { if (isset($rule['_value'])) { - $match = ($rule['_value'] instanceof \Closure) - ? $rule['_value']($value) - : $rule['_value'] == $value; + $match = $this->match($rule['_value'], $value); } else { - if (!is_string($rule['value']) && !is_numeric($rule['value'])) { + if (!is_string($rule['value']) && !is_numeric($rule['value']) && !is_array($rule['value'])) { throw new Exception('Wrong value type in relations config "' . $rule['value'] . '"'); } - $match = ($rule['value'] == $value); + $match = $this->match($rule['value'], $value); } if ($match) { @@ -172,6 +170,17 @@ return parent::_addResources(); } + protected function match($ruleValue, $targetValue) + { + if ($ruleValue instanceof \Closure) { + return $ruleValue($targetValue); + } + if (is_array($ruleValue)) { + return in_array($targetValue, $ruleValue); + } + return $ruleValue == $targetValue; + } + protected function isVisible($name) { foreach ($this->_dfRelations as $relation) { Index: www/js/jquery.dynamicForm.js =================================================================== --- www/js/jquery.dynamicForm.js (revision 5616) +++ www/js/jquery.dynamicForm.js (working copy) @@ -174,16 +174,29 @@ var result = [], match, i, length, targetValue = target.val(), ruleValue; for (i = 0, length = rules.length; i < length; ++i) { ruleValue = rules[i].value; - match = ('function' === $.type(ruleValue)) - ? (ruleValue.call(target, targetValue)) - : (targetValue == rules[i].value); - if (match) { + if (this.match(ruleValue, target)) { result.push(rules[i]); } } return result; }, + /** + * Test if element value match with rule value + * @param ruleValue + * @param target + */ + match: function (ruleValue, target) { + switch ($.type(ruleValue)) { + case 'function': + return ruleValue.call(target, target.val()); + case 'array': + return ruleValue.indexOf(target.val()) != -1; + default: + return (target.val() == ruleValue); + } + }, + /** * @param {Array.} rules Non matched rules * @return {*} @@ -225,8 +238,8 @@ /** @type {jQuery} */ this.plugin = options.plugin; - /** @type {String} */ - this.value = String(options.value); + /** @type {String}|{Array} */ + this.value = options.value; /** @type {Array.} */ this.rawNodes = options.nodes;