now got a working login form alongside the add-new-person form

master
Marek Isalski 6 years ago
parent 64ec097b4c
commit dc5a71e7f5

@ -401,24 +401,8 @@ function fulcrm_shoppingcart_buy_eventbookingtype_form_submit( $form, &$form_sta
$form_state[ 'fulcrm_shoppingcart' ][ 'shoppingcart' ] = $cart;
}
function fulcrm_shoppingcart_buy_eventbookingtype_login_form_submit( $form, &$form_state ) {
user_login_submit( $form, $form_state );
$form_state[ 'redirect' ] = fulcrm_shoppingcart_buy_url( $form_state[ 'fulcrm_shoppingcart' ][ 'redirect_buy_product_id' ] );
}
function fulcrm_shoppingcart_buy_eventbookingtype_login_or_add_person_form_submit( $form, &$form_state ) {
if ( array_key_exists( 'submit', $form_state[ 'values' ] ) ) {
$action = $form_state[ 'values' ][ 'submit' ];
if ( $action === 'Log in' ) {
user_login_submit( $form, $form_state );
$form_state[ 'redirect' ] = fulcrm_shoppingcart_buy_url( $form_state[ 'fulcrm_shoppingcart' ][ 'redirect_buy_product_id' ] );
} elseif ( $action === 'XXX' ) {
} else {
die( print_r( $form_state[ 'values' ], 1 ) );
}
}
function fulcrm_shoppingcart_buy_eventbookingtype_guest_add_person_form_submit( $form, &$form_state ) {
die( print_r( $form_state[ 'values' ], 1 ) );
}
function fulcrm_shoppingcart_buy_eventbookingtype_form( $form, &$form_state, $person, $eventbookingtype, $product ) {
@ -502,6 +486,7 @@ function fulcrm_shoppingcart_buy_eventbookingtype_form( $form, &$form_state, $pe
$form[ 'new_person' ] = fulcrm_collection_to_form( 'person', $collection_data[ 'data' ], array() );
}
}
$form[ '#submit' ] = 'fulcrm_shoppingcart_buy_eventbookingtype_guest_add_person_form_submit';
}
$form[ 'actions' ] = array( '#type' => 'actions' );
@ -513,6 +498,27 @@ function fulcrm_shoppingcart_buy_eventbookingtype_form( $form, &$form_state, $pe
return $form;
}
function _fulcrm_shoppingcart_drupal_get_form_with_form_state( $form_id, $form_state ) {
$args = func_get_args();
array_shift( $args ); // Remove $form_id from the arguments.
array_shift( $args ); // Remove $form_state from the arguments.
$form_state[ 'build_info' ][ 'args' ] = $args;
return drupal_build_form( $form_id, $form_state );
}
function fulcrm_shoppingcart_buy_eventbookingtype_login_form_submit( $form, &$form_state ) {
user_login_submit( $form, $form_state );
$form_state[ 'redirect' ] = fulcrm_shoppingcart_buy_url( $form_state[ 'fulcrm_shoppingcart' ][ 'redirect_buy_product_id' ] );
}
function fulcrm_shoppingcart_buy_eventbookingtype_login_form( $form, &$form_state, $product_id ) {
$form = user_login( $form, $form_state );
$form_state[ 'fulcrm_shoppingcart' ][ 'redirect_buy_product_id' ] = $product_id;
//$form[ 'actions' ][ 'submit' ][ '#submit' ] = array( 'fulcrm_shoppingcart_buy_eventbookingtype_login_form_submit' );
return $form;
}
function fulcrm_shoppingcart_buy_eventbookingtype( $person, $eventbookingtype, $product ) {
$person_id = NULL;
if ( array_key_exists( 'id', $person ) )
@ -523,7 +529,7 @@ function fulcrm_shoppingcart_buy_eventbookingtype( $person, $eventbookingtype, $
case 'guest':
case 'user':
if ( user_is_anonymous() ) {
$user_login_form = drupal_get_form( 'user_login' );
$user_login_form = drupal_get_form( 'fulcrm_shoppingcart_buy_eventbookingtype_login_form', $product_id = $product[ 'id' ] );
$fulcrm_shoppingcart_buy_eventbookingtype_form = drupal_get_form( 'fulcrm_shoppingcart_buy_eventbookingtype_form', $person, $eventbookingtype, $product );
@ -545,7 +551,7 @@ function fulcrm_shoppingcart_buy_eventbookingtype( $person, $eventbookingtype, $
}
$form = drupal_get_form( 'fulcrm_shoppingcart_buy_eventbookingtype_form', $person, $eventbookingtype, $product );
return druapl_render( $form );
return drupal_render( $form );
}
function fulcrm_shoppingcart_buy_generic_product_form_submit( $form, &$form_state ) {

@ -9,7 +9,7 @@
<div class="panel-body">
<?php $user_login_form[ 'actions' ][ 'submit' ][ '#value' ] = 'Sign In'; ?>
<?php $user_login_form[ 'actions' ][ 'submit' ][ '#attributes' ][ 'class' ] = array( 'btn', 'btn-primary' ); ?>
<?php print drupal_render( $user_login_form ); ?>
<?php print render( $user_login_form ); ?>
</div>
</div>
</div>
@ -18,7 +18,7 @@
<div class="panel panel-info">
<div class="panel-heading"><h3 class="panel-title">Or continue your order by providing some details&hellip;</h3></div>
<div class="panel-body">
<?php print drupal_render( $fulcrm_shoppingcart_buy_eventbookingtype_form ); ?>
<?php print render( $fulcrm_shoppingcart_buy_eventbookingtype_form ); ?>
</div>
</div>
</div>

Loading…
Cancel
Save