Support

Account

Home Forums General Issues How to add fields in the edit or add post form (already existing)?

Helping

How to add fields in the edit or add post form (already existing)?

    • c.alle

    • September 10, 2019 at 9:44 pm

    Hi, I created a Group called “Event Custom Field” which contains 5 additional fields (text, checkbox etc …).

    In the backend it works perfectly, I can change the values ​​or add them in the post.

    To display a single field in my template I added this code and it works perfectly:

    <div class="um-event"><i class="fa fa-map-marker"></i> <strong>
              My custom field:
              </strong> <?php 
    		$id = $post_id = $event_id;
    	$value = get_field( 'match', $id );
    
    if( $value ) {
        echo $value;
    } else {
        echo '-';
    } ?></div>

    Now I would like to add the possibility to modify an existing post or create a new post by adding all the “Custom Fields” created in the “Event Custom Field” group.

    This is the code already existing in the form on my page:

    <h3><?php echo esc_html( $form_title ); ?></h3>
    <form id="um_event_form" enctype="multipart/form-data">
    	<div class="um-event-form-message"></div>
    	<div class="um-event-form-section">
    	<div class="um-event-form-field">
    		<label><?php esc_html_e( 'Event Title', 'um-events-pro' ); ?></label>
    		<input type="text" name="event_title" id="event_title" value="<?php echo esc_attr( $event_title ); ?>" />
    	</div>
    	<?php if ( um_events_show_image() ) : ?>
    	<div class="um-event-form-section">
    		<div class="um-event-image-bg" <?php echo $bg_url; ?>>
    			<input class="event__file" type="file" name="files" id="file"  />
    			<label for="file">
    			<i class="fa fa-upload" aria-hidden="true"></i>
    			<?php esc_html_e( 'Add Event Photo', 'um-events-pro' ); ?>
    			</label>
    		</div>
    	</div>
    	<?php endif; ?>
    	<div class="um-event-date-time-fields">
    		<div class="um-event-form-field">
    			<label><?php esc_html_e( 'Start Date', 'um-events-pro' ); ?></label>
    			<div class="um-event-date-options">
    			<input type="text" name="event_date_start" id="um_event_date_start" class="um-event-date-input" value="<?php echo esc_attr( $event_start ); ?>"  autocomplete="off" />
    			<input type="text" name="event_time_start" id="event_time" class="um-event-time"  value="<?php echo esc_attr( $event_time_start ); ?>"  autocomplete="off" />
    			<!--<a href="#" id="um-event-add-end"><?php esc_html_e( '+ End Time', 'um-events-pro' ); ?></a>-->
    			</div>
    		</div>
    		<div class="um-event-form-field um-event-end-date">
    			<label><?php esc_html_e( 'End Date', 'um-events-pro' ); ?></label>
    			<div class="um-event-date-options">
    			<input type="text" name="event_date_end" id="um_event_date_end" class="um-event-date-input" value="<?php echo esc_attr( $event_end ); ?>"  autocomplete="off" />
    			<input type="text" name="event_time_end" id="event_time"  class="um-event-time" value="<?php echo esc_attr( $event_time_end ); ?>" autocomplete="off" />
    			<!-- <a href="#" id="um-event-remove-end"><?php esc_html_e( '- End Time', 'um-events-pro' ); ?></a> -->
    			</div>
    		</div>
    	</div>
    
    	<div class="um-event-form-section" id="um-event-invites">
    		<h3><?php echo esc_html__( 'Event Details', 'um-events-pro' ); ?></h3>
    		<div class="um-event-form-field">
    			<label><?php esc_html_e( 'Event Location', 'um-events-pro' ); ?></label>
    			<textarea name="event_location" id="event_location"><?php echo wp_kses_post( $event_location ); ?></textarea>
    		</div>
    		</div>
    		<div class="um-event-form-section">
    			<?php if ( um_events_allow_description() ) : ?>
    			<div class="um-event-form-field">
    				<label><?php esc_html_e( 'Description', 'um-events-pro' ); ?></label>
    				<textarea name="event_description" id="event_description"><?php echo wp_kses_post( $event_description ); ?></textarea>
    			</div>
    			<?php endif; ?>
    			<?php if ( um_events_allow_tickets() ) : ?>
    			<div class="um-event-form-field">
    				<label><?php esc_html_e( 'Ticket URL', 'um-events-pro' ); ?></label>
    				<input type="text" name="event_ticket_url" id="event_ticket_url" value="<?php echo esc_attr( $event_ticket_url ); ?>" />
    			</div>
    			<?php endif; ?>
    		</div>
    	</div>
    	<?php um_events()->guests->display_guest_picker( $event_id ); ?>
    	<div class="um-event-form-field">
    		<input type="submit" name="submit_event" id="submit_event" value="<?php esc_attr_e( 'Submit Event', 'um-events-pro' ); ?>" />
    	</div>
    	<input type="hidden" name="event_id" id="um_event_id" value="<?php echo absint( $id ); ?>" />
    </form>

    How can I add fields created with ACF to my form? It’s possible?

    Thank you.

  • https://theeventscalendar.com/support/forums/topic/adding-new-fields-to-community-events-form/

    According to the above, to add custom fields you would need to override the form template by creating your own. You can add fields inside the form by using acf_form() with 'form' => false, https://www.advancedcustomfields.com/resources/acf_form/

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.