Plugin Directory

Changeset 1684774


Ignore:
Timestamp:
06/24/2017 03:23:08 PM (9 years ago)
Author:
robby.roboter
Message:

custom field start index from 0, add clear

Location:
redi-restaurant-reservation/branches/custom_fields_API
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • redi-restaurant-reservation/branches/custom_fields_API/redi-restaurant-reservation.php

    r1623265 r1684774  
    460460                $this->options[ 'customfields_save_to' ] = CustomFieldsSaveTo::API;
    461461
    462                 for ( $i = 1; $i != CUSTOM_FIELDS; $i++ ) {
     462                for ( $i = 0; $i != CUSTOM_FIELDS; $i++ ) {
    463463                    $field_id       = 'field_' . $i . '_id';
    464464                    $field_name     = 'field_' . $i . '_name';
     
    630630                    // Get custom fields from wordpress options
    631631                    $custom_fields = array();
    632                     for ( $i = 1; $i != CUSTOM_FIELDS; $i ++ ) {
     632                    for ( $i = 0; $i != CUSTOM_FIELDS; $i ++ ) {
    633633                        $field_name     = 'field_' . $i . '_name';
    634634                        $field_type     = 'field_' . $i . '_type';
     
    10581058                // Get custom fields from wordpress options
    10591059                $custom_fields = array();
    1060                 for ( $i = 1; $i != CUSTOM_FIELDS; $i ++ ) {
     1060                for ( $i = 0; $i != CUSTOM_FIELDS; $i ++ ) {
    10611061                    $field_name     = 'field_' . $i . '_name';
    10621062                    $field_type     = 'field_' . $i . '_type';
     
    14851485                    $comment        = '';
    14861486                    $parameters = array();
    1487                     for ( $i = 1; $i != CUSTOM_FIELDS; $i ++ ) {
     1487                    for ( $i = 0; $i != CUSTOM_FIELDS; $i++ ) {
    14881488                        if ( isset( $_POST[ 'field_' . $i ] ) ) {
    14891489
  • redi-restaurant-reservation/branches/custom_fields_API/templates/admin.php

    r1623265 r1684774  
    5757        }
    5858    }
    59     jQuery(function () {
    60         jQuery('#add_field').on('click', function(){
    61             alert(1);
    62         });
    63     });
    64    
    6559</script>
    6660<?php $admin_slug = 'redi-restaurant-reservation-settings' ?>
     
    401395                        </label>
    402396                    </th>
     397                    <th>
     398
     399                    </th>
    403400                </tr>
    404401            </thead>
    405             <?php //foreach($custom_fields as $i => $custom_field):?>
    406             <?php for ( $i = 1; $i != CUSTOM_FIELDS; $i ++ ):
     402
     403            <?php  for ( $i = 0; $i != CUSTOM_FIELDS; $i++ ):
    407404                if ( ! isset( $custom_fields[ $i ] ) ) {
    408405                    $custom_fields[ $i ] = (object) array(
     
    417414            ?>
    418415            <?php $field_id = ('field_'.$i.'_id');?>
    419             <input type="hidden" id="<?php echo $field_id;?>" name="<?php echo $field_id;?>" value="<?php  echo $custom_field->Id ?>" />
     416
    420417            <tr>
    421418                <td>
     419                    <input type="hidden" id="<?php echo $field_id;?>" name="<?php echo $field_id;?>" value="<?php  echo $custom_field->Id ?>" />
    422420                    <?php $field_name=('field_'.$i.'_name'); ?>
    423421                    <input type="text" id="<?php echo $field_name; ?>" name="<?php echo $field_name; ?>" value="<?php echo $custom_field->Name; ?>"/>
     
    425423                <td style="vertical-align: top;">
    426424                    <?php $field_type=('field_'.$i.'_type'); ?>
    427                     <select onchange="set_name('<?php echo $field_name; ?>',this.options[this.selectedIndex].value);" class="field_type" name="<?php echo $field_type; ?>">
     425                    <select onchange="set_name('<?php echo $field_name; ?>',this.options[this.selectedIndex].value);" class="field_type" name="<?php echo $field_type; ?>" id="<?php echo $field_type; ?>">
    428426                        <option value="text" <?php if ($custom_field->Type === 'text'):?>selected="selected"<?php endif?>><?php _e('Text field', 'redi-restaurant-reservation'); ?></option>
    429427                        <option value="checkbox" <?php if ($custom_field->Type === 'checkbox'):?>selected="selected"<?php endif?>><?php _e('Check box', 'redi-restaurant-reservation'); ?></option>
     
    435433                <td>
    436434                    <?php $field_required=('field_'.$i.'_required'); ?>
    437                     <input type="checkbox" name="<?php echo $field_required; ?>" <?php if ($custom_field->Required): ?>checked="checked"<?php endif?>>
     435                    <input type="checkbox" id="<?php echo $field_required; ?>" name="<?php echo $field_required; ?>" <?php if ($custom_field->Required): ?>checked="checked"<?php endif?>>
    438436                </td>
    439437                <td>
    440438                    <?php $field_message=('field_'.$i.'_message'); ?>
    441                     <input type="text" name="<?php echo $field_message;?>" value="<?php echo $custom_field->Message ?>" style="width:250px;">
    442                 </td>
    443             </tr>
    444            
    445             <?php endfor; // endforeach; ?>
     439                    <input type="text" id="<?php echo $field_message;?>" name="<?php echo $field_message;?>" value="<?php echo $custom_field->Message ?>" style="width:250px;">
     440                </td>
     441                <td>
     442                    <a onclick="jQuery('#<?php echo $field_name; ?>').val(''); jQuery('#<?php echo $field_message; ?>').val(''); jQuery('#<?php echo $field_required; ?>').attr('checked', false);">clear</a>
     443                </td>
     444            </tr>
     445
     446            <?php endfor; ?>
    446447        </table>
    447 <!--        <a href="#" id="add_field" >add another field</a>-->
    448448        <!-- /custom fields-->                     
    449449        <p class="description">
Note: See TracChangeset for help on using the changeset viewer.