• Resolved jakfre

    (@jakfre)


    Hello,

    Is it possible to add default value for an additional field?

    I’ve referred to this https://givewp.com/documentation/developers/how-to-create-custom-form-fields/ article and made an additional text field. But I need to add a default value for that text field.

    Ex: I need an additional form field called “Birth City” in the donation form and its default value should be “London”

    add_action( ‘give_fields_after_donation_amount’, function( $collection ) {
    $collection->append(
    give_field( ‘text’, ‘Birth City” )
    ->showInReceipt()
    ->label( __(‘Birth City’) )
    ->value(‘London’)
    ->storeAsDonorMeta()
    ->required()
    ->helpText( __( ‘This is a field used to add your birth city.’ ) )
    );
    });

    I just added this code, but it shows an error. ->value(‘London’) here is the place I got stuck. It’s urgent, Please advice

    Thanks

Viewing 1 replies (of 1 total)
  • Hi @jakfre,

    I sent along a snippet for you on your other ticket, so be sure to give that a look! I’ll go ahead and mark this ticket as resolved for now, if you have any other questions you can create a new ticket here and we’ll get you squared away. Have a great day!

Viewing 1 replies (of 1 total)
  • The topic ‘Set a dfualt value for custom field’ is closed to new replies.