| @@ -25,9 +25,14 @@ | ||
| 25 | 25 | |
| 26 | 26 | if(!isset($field->hint))$field->hint = ''; |
| 27 | 27 | if(!isset($field->columns_number))$field->columns_number = ''; |
| 28 | 28 | if(!isset($field->class))$field->class = ''; |
| 29 | +if(!isset($field->prefix))$field->prefix = ''; | |
| 30 | +if(!isset($field->suffix))$field->suffix = ''; | |
| 31 | +if(!isset($field->default))$field->default = ''; | |
| 32 | +if(!isset($field->empty_default))$field->empty_default = ''; | |
| 29 | 33 | |
| 34 | + | |
| 30 | 35 | $field_label = $field->field_label; |
| 31 | 36 | |
| 32 | 37 | $required = ''; |
| 33 | 38 | if(isset($field->is_required) && $field->is_required == 1) |
| @@ -34,18 +39,37 @@ | ||
| 34 | 39 | $required = '*'; |
| 35 | 40 | |
| 36 | 41 | if(isset($field->rules) && strpos($field->rules, 'required') !== FALSE) |
| 37 | 42 | $required = '*'; |
| 38 | - | |
| 39 | 43 | ?> |
| 40 | 44 | |
| 41 | -<div class="wdk-field-edit <?php echo esc_attr($field->field_type); ?> wdk-col-<?php echo esc_attr($field->columns_number); ?> <?php echo esc_attr($field->class); ?>"> | |
| 45 | +<div class="wdk-field-<?php echo esc_attr($field_id);?> wdk-field-edit <?php echo esc_attr($field->field_type); ?> wdk-col-<?php echo esc_attr($field->columns_number); ?> <?php echo esc_attr($field->class); ?> <?php if(!empty($form) && method_exists($form, 'hasError') && $form->hasError($field_id)):?> field-error <?php endif;?>"> | |
| 42 | 46 | <label for="<?php echo esc_attr($field_id); ?>"><?php echo esc_html($field_label).esc_html($required); ?></label> |
| 43 | 47 | <div class="wdk-field-container"> |
| 44 | - <input class="regular-text" name="<?php echo esc_attr($field_id); ?>" type="text" id="<?php echo esc_attr($field_id); ?>" value="<?php echo esc_attr(wmvc_show_data($field_id, $db_data, '')); ?>"> | |
| 48 | + <input class="regular-text" | |
| 49 | + name="<?php echo esc_attr($field_id); ?>" | |
| 50 | + type="text" id="<?php echo esc_attr($field_id); ?>" | |
| 51 | + value="<?php echo esc_attr(!empty(wmvc_show_data($field_id, $db_data, $field->default)) ? wmvc_show_data($field_id, $db_data, $field->default) : $field->empty_default); ?>" | |
| 52 | + > | |
| 53 | + <span class="suffix"><?php | |
| 54 | + // Dynamic field values are registered in the translation catalog separately. | |
| 55 | + // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText | |
| 56 | + echo esc_html__($field->prefix, 'wpdirectorykit'); | |
| 57 | + if(!empty($field->prefix) && !empty($field->suffix)) echo ' / '; | |
| 58 | + // Dynamic field values are registered in the translation catalog separately. | |
| 59 | + // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText | |
| 60 | + echo esc_html__($field->suffix, 'wpdirectorykit'); | |
| 61 | + ?></span> | |
| 45 | 62 | <?php if(!empty($field->hint)):?> |
| 46 | 63 | <p class="wdk-hint"> |
| 47 | 64 | <?php echo wp_kses_post($field->hint); ?> |
| 48 | 65 | </p> |
| 49 | 66 | <?php endif;?> |
| 67 | + <?php if(!empty($form) && method_exists($form, 'hasError') && $form->getError($field_id)):?> | |
| 68 | + <p class="wdk-hint wdk-error"> | |
| 69 | + <?php echo wp_kses_post($form->getError($field_id)); ?> | |
| 70 | + </p> | |
| 71 | + <?php endif;?> | |
| 50 | 72 | </div> |
| 51 | -</div> | |
| 73 | +</div> | |
| 74 | + | |
| 75 | +<?php | |