*
* @param array $params (reference) an assoc array of name/value pairs
*
- * @return object CRM_Core_DAO_CustomField object
+ * @return CRM_Core_DAO_CustomField object
* @access public
* @static
*/
// reset the cache
CRM_Core_BAO_Cache::deleteGroup('contact fields');
- CRM_Core_Session::setStatus(ts('Your custom field \'%1\' has been saved.',
- array(1 => $customField->label)
- ), ts('Saved'), 'success');
+ $msg = '<p>' . ts("Custom field '%1' has been saved.", array(1 => $customField->label)) . '</p>';
$buttonName = $this->controller->getButtonName();
$session = CRM_Core_Session::singleton();
if ($buttonName == $this->getButtonName('next', 'new')) {
- CRM_Core_Session::setStatus(ts(' You can add another custom field.'), '', 'info');
+ $msg += '<p>' . ts("Ready to add another.") . '</p>';
$session->replaceUserContext(CRM_Utils_System::url('civicrm/admin/custom/group/field/add',
'reset=1&action=add&gid=' . $this->_gid
));
'reset=1&action=browse&gid=' . $this->_gid
));
}
+ $session->setStatus($msg, ts('Saved'), 'success');
+
+ // Add data when in ajax contect
+ $this->ajaxResponse['customField'] = $customField->toArray();
}
}
*/
getFieldByName: function(entityName, fieldName) {
return this.find(function(paletteFieldModel) {
- return (paletteFieldModel.get('entityName') == entityName && paletteFieldModel.get('fieldName') == fieldName);
+ return ((!entityName || paletteFieldModel.get('entityName') == entityName) && paletteFieldModel.get('fieldName') == fieldName);
});
},
CRM.loadForm(url, {
resetButton: 'next_new',
onSuccess: function(data, settings) {
- paletteView.doRefresh();
+ paletteView.doRefresh('custom_' + data.customField.id);
if (data.buttonName != 'next_new') {
$(settings.target).dialog('close');
}
});
return false;
},
- doRefresh: function() {
+ doRefresh: function(fieldToAdd) {
var ufGroupModel = this.model;
CRM.Schema.reloadModels()
.done(function(data){
ufGroupModel.resetEntities();
+ if (fieldToAdd) {
+ var field = ufGroupModel.getRel('paletteFieldCollection').getFieldByName(null, fieldToAdd);
+ field.addToUFCollection(ufGroupModel.getRel('ufFieldCollection'));
+ }
})
.fail(function() {
CRM.alert(ts('Failed to retrieve schema'), ts('Error'), 'error');