• Resolved olive.house

    (@olivehouse-1)


    I know how to create a simple custom field within a textarea and show this on the frontend (https://wpjobmanager.com/document/tutorial-adding-a-salary-field-for-jobs/).

    However the information I want the customer to enter when submitting their job is more complex than a single text area, its a table of 2 drop downs and 1 text area. Therefore I am struggling to understand how I can submit all that information as one function.

    This is how i would do it if it was a single text box.

    function frontend_add_rates_field( $fields ) {
      $fields['job']['studio-rates'] = array(
        'label'       => __( 'Studio Rates', 'job_manager' ),
        'type'        => 'text',
        'required'    => false,
        'placeholder' => '123',
        'priority'    => 7
      );
      return $fields;
    add_filter( 'submit_job_form_fields', 'frontend_add_rates_field' );

    But this is kinda what I am trying. It shows on the job submit page but it doesnt submit the information anywhere because I am not saving the information to anything. I just cant work out how to save it.

    function frontend_add_rates_field( $fields ) {
      ?>
      <div class="rates-table-frontend">
    	<script src="http://bookastudio.co.uk/wp-content/themes/listify-child/js/rates-table.js"></script>
    	<label for="rate">Studio Rate</label>
    	<TABLE id="dataTable" width="350px" border="1" style="margin-bottom:6px">
    		<TR>
    		<TD><label>Duration</label></TD>
    		<TD><label>Type</label></TD>
    		<TD><label>Price (£)</label></TD>
    		<TD><label>Remove?</label></TD>
    		</TR>
    		<TR>
    			<TD>
    				<SELECT name="duration[]">
    					<OPTION value="1">1</OPTION>
    					<OPTION value="2">2</OPTION>
    					<OPTION value="3">3</OPTION>
    				</SELECT>
    			</TD>
    			<TD>
    				<SELECT name="type[]">
    					<OPTION value="hours">Hour/s</OPTION>
    					<OPTION value="days">Day/s</OPTION>
    				</SELECT>
    			</TD>
    			<TD><INPUT type="text" name="price[]" placeholder="e.g. 150 (for £150.00)"/></TD>
    			<TD><INPUT type="checkbox" name="chk" id="remove-rate-check"/></TD>
    		</TR>
    	</TABLE>
    	<INPUT class="remove-rates-table-button" type="button" value="Delete Row" onclick="deleteRow('dataTable')" />
    	<INPUT class="add-rates-table-button" type="button" value="Add Row" onclick="addRow('dataTable')" />
      </div>
      <?php
    	return $fields;
    }
     
    add_filter( 'submit_job_form_fields', 'frontend_add_rates_field' );
  • The topic ‘Add custom field to single listing with dropdown & textarea’ is closed to new replies.