/** * Supports setting metadata on both models. The MyListForm model and the SearchModel * @see ModalConfigEditView::setMetadataFromPost() */ public function setMetadataFromPost($postArray) { parent::setMetadataFromPost($postArray); $sanitizedPostArray = PostUtil::sanitizePostByDesignerTypeForSavingModel($this->searchModel, ArrayUtil::getArrayValue($_POST, $this->getSearchModelPostArrayName())); $searchAttributes = SearchUtil::getSearchAttributesFromSearchArrayForSavingExistingSearchCriteria($sanitizedPostArray); $searchAttributesAdaptedToSetInModel = SearchUtil::adaptSearchAttributesToSetInRedBeanModel($searchAttributes, $this->searchModel); $this->searchAttributes = $searchAttributesAdaptedToSetInModel; }
public function testAdaptSearchAttributesToSetInRedBeanModel() { $model = new ASearchFormTestModel(new A(false)); $searchAttributes = array('differentOperatorB' => array('value' => 'thiswillstay'), 'a' => array('value' => 'thiswillgo'), 'differentOperatorB' => 'something', 'name' => array('value' => 'thiswillstay')); $adaptedSearchAttributes = SearchUtil::adaptSearchAttributesToSetInRedBeanModel($searchAttributes, $model); $compareData = array('differentOperatorB' => array('value' => 'thiswillstay'), 'a' => 'thiswillgo', 'differentOperatorB' => 'something', 'name' => array('value' => 'thiswillstay')); $this->assertEquals($compareData, $adaptedSearchAttributes); }