Skip to content

Commit

Permalink
Merge pull request #171 from mecachisenros/revert-164-master
Browse files Browse the repository at this point in the history
Revert "#140 Address custom fields support"
  • Loading branch information
mecachisenros authored Jul 21, 2020
2 parents 1b22789 + a34ea67 commit fe03d53
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 79 deletions.
35 changes: 0 additions & 35 deletions includes/class-civicrm-caldera-forms-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1099,41 +1099,6 @@ public function get_participant_custom_fields() {

}

/**
* Get a Address custom fields.
*
* @since 1.0
* @return array $custom_fields The array of custom fields - e.g. ['custom_x' => 'Label of custom_x']
*/
public function get_address_custom_fields() {

try {
$custom_groups = civicrm_api3( 'CustomGroup', 'get', [
'sequential' => 1,
'is_active' => 1,
'extends' => 'Address',
'api.CustomField.get' => [ 'is_active' => 1, 'options' => [ 'limit' => 0 ] ],
'options' => [ 'limit' => 0 ],
] );
} catch ( CiviCRM_API3_Exception $e ) {
return [ 'note' => $e->getMessage(), 'type' => 'error' ];
}

$custom_fields = [];
foreach ( $custom_groups['values'] as $key => $custom_group ) {
foreach ( $custom_group['api.CustomField.get']['values'] as $k => $custom_field ) {
$custom_fields['custom_' . $custom_field['id']] = [
'label' => $custom_field['label'],
'extends_entity_column_id' => $custom_group['extends_entity_column_id'],
'extends_entity_column_value' => $custom_group['extends_entity_column_value']
];
}
}

return $custom_fields;

}

/**
* Get processor by type.
*
Expand Down
15 changes: 0 additions & 15 deletions processors/address/address_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,3 @@
<?php } } ?>

<hr style="clear: both;" />

<h2><?php _e( 'Custom Fields', 'cf-civicrm' ); ?></h2>
<?php foreach ( caldera_forms_civicrm()->helper->get_address_custom_fields() as $key => $custom_field ) { ?>
<div
id="{{_id}}_<?php echo esc_attr( $key ); ?>"
class="caldera-config-group"
data-entity-column-id="<?php echo esc_attr( $custom_field['extends_entity_column_id'] ); ?>"
data-entity-column-value="<?php echo esc_attr( json_encode( $custom_field['extends_entity_column_value'] ) ); ?>"
>
<label><?php echo esc_html( $custom_field['label'] ); ?> </label>
<div class="caldera-config-field">
<?php echo '{{{_field slug="' . $key . '"}}}'; ?>
</div>
</div>
<?php } ?>
17 changes: 2 additions & 15 deletions processors/address/class-address-processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class CiviCRM_Caldera_Forms_Address_Processor {
*/
public $key_name = 'civicrm_address';

public $fields = [ 'name', 'is_primary', 'is_billing', 'street_address', 'supplemental_address_1', 'supplemental_address_2', 'city', 'state_province_id', 'postal_code', 'country_id', 'geo_code_1', 'geo_code_2' ];
public $fields = [ 'name', 'is_primary', 'is_billing', 'street_address', 'supplemental_address_1', 'supplemental_address_2', 'city', 'state_province_id', 'postal_code', 'country_id' ];

/**
* Fields to ignore while prepopulating
Expand All @@ -45,8 +45,7 @@ public function __construct( $plugin ) {
add_filter( 'caldera_forms_get_form_processors', [ $this, 'register_processor' ] );
// filter form before rendering
add_filter( 'caldera_forms_render_get_form', [ $this, 'pre_render' ] );
// address custom fields
add_filter( 'cfc_custom_fields_extends_entities', [ $this, 'custom_fields_extend_address' ] );

}

/**
Expand Down Expand Up @@ -185,16 +184,4 @@ public function pre_render( $form ){

return $form;
}

/**
* Add Address to extend custom fields autopopulation/presets.
*
* @since 1.0
* @param array $extends The entites array
* @return array $extends The filtered entities array
*/
public function custom_fields_extend_address( $extends ) {
$extends[] = 'Address';
return $extends;
}
}
14 changes: 0 additions & 14 deletions processors/contact/contact_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,20 +229,6 @@
</div>
<?php } } ?>
<hr style="clear: both;" />

<h2 style="display: inline-block;"><?php _e( 'Address Custom Fields', 'cf-civicrm' ); ?></h2>
<?php
$addressCustomFields = caldera_forms_civicrm()->helper->get_address_custom_fields();
foreach( $addressCustomFields as $key => $value ) { ?>
<div id="<?php echo esc_attr( $key ); ?>" class="caldera-config-group" data-crm-type="<?php echo caldera_forms_civicrm()->helper->custom_field_extends( $key ); ?>">
<label><?php echo esc_html( $value['label'] ); ?></label>
<div class="caldera-config-field">
<input type="text" class="block-input field-config magic-tag-enabled caldera-field-bind" id="{{_id}}" name="{{_name}}[civicrm_address][<?php echo $key; ?>]" value="{{<?php echo 'civicrm_address/' . $key; ?>}}">
</div>
</div>
<?php } ?>
<hr style="clear: both;" />

</div>
</div>

Expand Down

0 comments on commit fe03d53

Please sign in to comment.