| @@ -16,9 +16,9 @@ | ||
| 16 | 16 | $values = FrmAppHelper::maybe_filter_array( $values, array( 'name', 'description' ) ); |
| 17 | 17 | |
| 18 | 18 | $new_values = array( |
| 19 | 19 | 'form_key' => FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key' ), |
| 20 | - 'name' => $values['name'], | |
| 20 | + 'name' => FrmAppHelper::truncate( $values['name'], 255, 1, '', true ), | |
| 21 | 21 | 'description' => $values['description'], |
| 22 | 22 | 'status' => $values['status'] ?? 'published', |
| 23 | 23 | 'logged_in' => $values['logged_in'] ?? 0, |
| 24 | 24 | 'is_template' => isset( $values['is_template'] ) ? (int) $values['is_template'] : 0, |
| @@ -165,8 +165,10 @@ | ||
| 165 | 165 | /** |
| 166 | 166 | * Switches field ID in fields. |
| 167 | 167 | * |
| 168 | 168 | * @since 5.3 |
| 169 | + * @since 6.35 The description column is checked too, so a field id in a description survives a | |
| 170 | + * duplicate or import when the field it points at is created afterwards. | |
| 169 | 171 | * |
| 170 | 172 | * @param int $form_id Form ID. |
| 171 | 173 | * |
| 172 | 174 | * @return void |
| @@ -174,9 +176,9 @@ | ||
| 174 | 176 | private static function switch_field_ids_in_fields( $form_id ) { |
| 175 | 177 | global $wpdb; |
| 176 | 178 | |
| 177 | 179 | // Keys of fields that you want to check to replace field ID. |
| 178 | - $keys = array( 'default_value', 'field_options' ); | |
| 180 | + $keys = array( 'default_value', 'description', 'field_options' ); | |
| 179 | 181 | $sql_cols = 'fi.id'; |
| 180 | 182 | |
| 181 | 183 | foreach ( $keys as $key ) { |
| 182 | 184 | $sql_cols .= ',fi.' . $key; |
| @@ -267,9 +269,9 @@ | ||
| 267 | 269 | $new_values = self::set_update_options( array(), $values, array( 'form_id' => $id ) ); |
| 268 | 270 | |
| 269 | 271 | foreach ( $values as $value_key => $value ) { |
| 270 | 272 | if ( $value_key && in_array( $value_key, $form_fields, true ) ) { |
| 271 | - $new_values[ $value_key ] = $value; | |
| 273 | + $new_values[ $value_key ] = 'name' === $value_key ? FrmAppHelper::truncate( $value, 255, 1, '', true ) : $value; | |
| 272 | 274 | } |
| 273 | 275 | } |
| 274 | 276 | |
| 275 | 277 | if ( ! empty( $values['new_status'] ) ) { |