| @@ -27,9 +27,12 @@ | ||
| 27 | 27 | if(!isset($field->columns_number))$field->columns_number = ''; |
| 28 | 28 | if(!isset($field->class))$field->class = ''; |
| 29 | 29 | if(!isset($field->prefix))$field->prefix = ''; |
| 30 | 30 | if(!isset($field->suffix))$field->suffix = ''; |
| 31 | +if(!isset($field->default))$field->default = ''; | |
| 32 | +if(!isset($field->empty_default))$field->empty_default = ''; | |
| 31 | 33 | |
| 34 | + | |
| 32 | 35 | $field_label = $field->field_label; |
| 33 | 36 | |
| 34 | 37 | $required = ''; |
| 35 | 38 | if(isset($field->is_required) && $field->is_required == 1) |
| @@ -36,19 +39,26 @@ | ||
| 36 | 39 | $required = '*'; |
| 37 | 40 | |
| 38 | 41 | if(isset($field->rules) && strpos($field->rules, 'required') !== FALSE) |
| 39 | 42 | $required = '*'; |
| 40 | - | |
| 41 | 43 | ?> |
| 42 | 44 | |
| 43 | -<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;?>"> | |
| 44 | 46 | <label for="<?php echo esc_attr($field_id); ?>"><?php echo esc_html($field_label).esc_html($required); ?></label> |
| 45 | 47 | <div class="wdk-field-container"> |
| 46 | - <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 | + > | |
| 47 | 53 | <span class="suffix"><?php |
| 48 | - echo esc_html($field->prefix); | |
| 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'); | |
| 49 | 57 | if(!empty($field->prefix) && !empty($field->suffix)) echo ' / '; |
| 50 | - echo esc_html($field->suffix); | |
| 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'); | |
| 51 | 61 | ?></span> |
| 52 | 62 | <?php if(!empty($field->hint)):?> |
| 53 | 63 | <p class="wdk-hint"> |
| 54 | 64 | <?php echo wp_kses_post($field->hint); ?> |
| @@ -53,6 +63,13 @@ | ||
| 53 | 63 | <p class="wdk-hint"> |
| 54 | 64 | <?php echo wp_kses_post($field->hint); ?> |
| 55 | 65 | </p> |
| 56 | 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;?> | |
| 57 | 72 | </div> |
| 58 | -</div> | |
| 73 | +</div> | |
| 74 | + | |
| 75 | +<?php | |