add settings page with relevant variables

master
Marek Isalski 9 years ago
parent fa75305d86
commit b77423e5af

@ -1,6 +1,13 @@
<?php
function fulcrm_shoppingcart_admin_form_submit( $form, &$form_state ) {
variable_set( 'fulcrm_shoppingcart_proceed_text', $form_state[ 'values' ][ 'proceed_text' ] );
variable_set( 'fulcrm_shoppingcart_proceed_url', $form_state[ 'values' ][ 'proceed_url' ] );
variable_set( 'fulcrm_shoppingcart_success_url', $form_state[ 'values' ][ 'success_url' ] );
variable_set( 'fulcrm_shoppingcart_failure_url', $form_state[ 'values' ][ 'failure_url' ] );
drupal_set_message( t('Settings saved.'), 'status' );
}
function fulcrm_shoppingcart_admin_form( $form, &$form_state ) {
@ -11,6 +18,35 @@ function fulcrm_shoppingcart_admin_form( $form, &$form_state ) {
'#description' => '',
);
$form[ 'proceed_text' ] = array( '#type' => 'textfield',
'#title' => 'Link text to carry on shopping',
'#default_value' => variable_get( 'fulcrm_shoppingcart_proceed_text', 'Keep shopping' ),
);
$form[ 'proceed_url' ] = array( '#type' => 'textfield',
'#title' => 'URL to go to to carry on shopping',
'#default_value' => variable_get( 'fulcrm_shoppingcart_proceed_url', url( '<front>', array( 'absolute' => true ) ) ),
);
$form[ 'fulcrm_url' ] = array( '#type' => 'fieldset',
'#title' => 'Return URLs',
);
$form[ 'fulcrm_url' ][ 'success_url' ] = array( '#type' => 'textfield',
'#title' => 'URL to return to upon transaction success',
'#default_value' => variable_get( 'fulcrm_shoppingcart_success_url', url( '<front>', array( 'absolute' => true ) ) ),
);
$form[ 'fulcrm_url' ][ 'failure_url' ] = array( '#type' => 'textfield',
'#title' => 'URL to return to upon transaction failure',
'#default_value' => variable_get( 'fulcrm_shoppingcart_failure_url', url( '<front>', array( 'absolute' => true ) ) ),
);
$form[ 'actions' ] = array( '#type' => 'actions' );
$form[ 'actions' ][ 'save' ] = array( '#type' => 'submit',
'#value' => t('Save'),
'#submit' => array( 'fulcrm_shoppingcart_admin_form_submit' ),
);
return $form;
}

Loading…
Cancel
Save