addElement('text', 'name', ts('Find Target Household')); $this->add('select', 'relationship_type_id', ts('Relationship Type'), array( '' => ts('- select -'), ) + CRM_Contact_BAO_Relationship::getRelationType("Household"), TRUE ); $searchRows = $this->get('searchRows'); $searchCount = $this->get('searchCount'); if ($searchRows) { $checkBoxes = array(); $checkFlag = 0; foreach ($searchRows as $id => $row) { if (!$checkFlag) { $checkFlag = $id; } $checkBoxes[$id] = $this->createElement('radio', NULL, NULL, NULL, $id); } $this->addGroup($checkBoxes, 'contact_check'); if ($checkFlag) { $checkBoxes[$checkFlag]->setChecked(TRUE); } $this->assign('searchRows', $searchRows); } $this->assign('searchCount', $searchCount); $this->assign('searchDone', $this->get('searchDone')); $this->assign('contact_type_display', ts('Household')); $this->addElement('submit', $this->getButtonName('refresh'), ts('Search'), array('class' => 'crm-form-submit')); $this->addElement('submit', $this->getButtonName('cancel'), ts('Cancel'), array('class' => 'crm-form-submit')); $this->addButtons(array( array( 'type' => 'next', 'name' => ts('Add to Household'), 'isDefault' => TRUE, ), array( 'type' => 'cancel', 'name' => ts('Cancel'), ), ) ); } /** * Process the form after the input has been submitted and validated. */ public function postProcess() { // store the submitted values in an array $this->params = $this->controller->exportValues($this->_name); $this->set('searchDone', 0); if (!empty($_POST['_qf_AddToHousehold_refresh'])) { $searchParams['contact_type'] = array('Household' => 'Household'); $searchParams['rel_contact'] = $this->params['name']; $this->search($this, $searchParams); $this->set('searchDone', 1); return; } $this->addRelationships(); } }