*/
public $_surveyId;
+ /**
+ * Explicitly declare the entity api name.
+ */
+ public function getDefaultEntity() {
+ return 'Survey';
+ }
+
+ /**
+ * Get the entity id being edited.
+ *
+ * @return int|null
+ */
+ public function getEntityId() {
+ return $this->_surveyId;
+ }
+
public function preProcess() {
if (!CRM_Campaign_BAO_Campaign::accessCampaign()) {
CRM_Utils_System::permissionDenied();
}
}
- // when custom data is included in this page
- if (!empty($_POST['hidden_custom'])) {
- $this->set('type', 'Event');
- $this->set('entityId', $this->_surveyId);
- CRM_Custom_Form_CustomData::preProcess($this, NULL, NULL, 1, 'Survey', $this->_surveyId);
- CRM_Custom_Form_CustomData::buildQuickForm($this);
- CRM_Custom_Form_CustomData::setDefaultValues($this);
- }
+ // Add custom data to form
+ CRM_Custom_Form_CustomData::addToForm($this);
$session = CRM_Core_Session::singleton();
$url = CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=survey');
$this->assign('action', $this->_action);
$this->assign('surveyId', $this->_surveyId);
- // for custom data
- $this->assign('entityID', $this->_surveyId);
if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::DELETE)) {
$this->_surveyId = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
$params['is_active'] = CRM_Utils_Array::value('is_active', $params, 0);
$params['is_default'] = CRM_Utils_Array::value('is_default', $params, 0);
- $customFields = CRM_Core_BAO_CustomField::getFields('Survey');
- $params['custom'] = CRM_Core_BAO_CustomField::postProcess($params,
- $this->_surveyId,
- 'Survey'
- );
+ $params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $this->getEntityId(), $this->getDefaultEntity());
$surveyId = CRM_Campaign_BAO_Survey::create($params);
*/
protected $_surveyTitle;
+ /**
+ * Explicitly declare the entity api name.
+ */
+ public function getDefaultEntity() {
+ return 'Survey';
+ }
+
+ /**
+ * Get the entity id being edited.
+ *
+ * @return int|null
+ */
+ public function getEntityId() {
+ return $this->_surveyId;
+ }
+
public function preProcess() {
if (!CRM_Campaign_BAO_Campaign::accessCampaign()) {
CRM_Utils_System::permissionDenied();
$this->assign('action', $this->_action);
$this->assign('surveyId', $this->_surveyId);
- // when custom data is included in this page
- if (!empty($_POST['hidden_custom'])) {
- $this->set('type', 'Survey');
- $this->set('entityId', $this->_surveyId);
- CRM_Custom_Form_CustomData::preProcess($this, NULL, NULL, 1, 'Survey', $this->_surveyId);
- CRM_Custom_Form_CustomData::buildQuickForm($this);
- CRM_Custom_Form_CustomData::setDefaultValues($this);
- }
+ // Add custom data to form
+ CRM_Custom_Form_CustomData::addToForm($this);
// CRM-11480, CRM-11682
// Preload libraries required by the "Questions" tab
*/
protected $_context;
- /**
- * Explicitly declare the entity api name.
- */
- public function getDefaultEntity() {
- return 'Survey';
- }
-
public function preProcess() {
parent::preProcess();
CRM_Utils_System::setTitle(ts('Configure Survey') . ' - ' . $this->_surveyTitle);
}
- // when custom data is included in this page
- if (!empty($_POST['hidden_custom'])) {
- CRM_Custom_Form_CustomData::preProcess($this);
- CRM_Custom_Form_CustomData::buildQuickForm($this);
- }
+ // Add custom data to form
+ CRM_Custom_Form_CustomData::addToForm($this);
if ($this->_name != 'Petition') {
$url = CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=survey');
$this->assign('action', $this->_action);
$this->assign('surveyId', $this->_surveyId);
- // for custom data
- $this->assign('entityID', $this->_surveyId);
}
/**
$params['is_active'] = CRM_Utils_Array::value('is_active', $params, 0);
$params['is_default'] = CRM_Utils_Array::value('is_default', $params, 0);
- $params['custom'] = CRM_Core_BAO_CustomField::postProcess($params,
- $this->_surveyId,
- 'Survey'
- );
+ $params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $this->getEntityId(), $this->getDefaultEntity());
+
$survey = CRM_Campaign_BAO_Survey::create($params);
$this->_surveyId = $survey->id;
</tr>
</table>
- <div id="customData"></div>
+ {include file="CRM/common/customDataBlock.tpl"}
{/if}
<div class="crm-submit-buttons">
{include file="CRM/common/formButtons.tpl" location="bottom"}
</div>
</div>
-
-{* include custom data js *}
-{include file="CRM/common/customData.tpl"}
-
-{literal}
-<script type="text/javascript">
- CRM.$(function($) {
- {/literal}{if $customDataSubType}
- CRM.buildCustomData( '{$customDataType}', {$customDataSubType} );
- {else}
- CRM.buildCustomData( '{$customDataType}' );
- {/if}
- {literal}
- });
-</script>
-{/literal}
</td>
</tr>
</table>
- <div id="customData"></div>
- {*include custom data js file*}
- {include file="CRM/common/customData.tpl"}
- {literal}
- <script type="text/javascript">
- CRM.$(function($) {
- {/literal}
- CRM.buildCustomData( 'Survey' );
- {literal}
- });
- </script>
- {/literal}
+ {include file="CRM/common/customDataBlock.tpl"}
{/if}
<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
</div>
</tr>
<tr class="crm-campaign-form-block-custom_data">
<td colspan="2">
- <div id="customData"></div>
+ {include file="CRM/common/customDataBlock.tpl"}
</td>
</tr>
</table>
- <div id="customData"></div>
- {*include custom data js file*}
- {include file="CRM/common/customData.tpl"}
- {literal}
- <script type="text/javascript">
- CRM.$(function($) {
- {/literal}
- CRM.buildCustomData( 'Survey' );
- {literal}
- });
- </script>
- {/literal}
<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
</div>
});
</script>
{/literal}
-{literal}
- <script type="text/javascript">
- CRM.$(function($) {
- {/literal}
- CRM.buildCustomData( 'Survey' );
- {literal}
- });
- </script>
-{/literal}
+++ /dev/null
-{* Edit custom data on Edit entity forms *}
-{* Requires <div id="customData"></div> on the form *}
-{*include custom data js file*}
-{include file="CRM/common/customData.tpl"}
-{literal}
-<script type="text/javascript">
- CRM.$(function($) {
- {/literal}
- CRM.buildCustomData( '{$customDataType}' );
- {if $customDataSubType}
- CRM.buildCustomData( '{$customDataType}', {$customDataSubType} );
- {/if}
- {literal}
- });
-</script>
-{/literal}
\ No newline at end of file