| @@ -64,8 +64,9 @@ | ||
| 64 | 64 | /** |
| 65 | 65 | * Gets entry property. |
| 66 | 66 | * |
| 67 | 67 | * @since 5.0.16 |
| 68 | + * | |
| 68 | 69 | * @return stdClass |
| 69 | 70 | */ |
| 70 | 71 | public function get_entry() { |
| 71 | 72 | return $this->entry; |
| @@ -114,8 +115,10 @@ | ||
| 114 | 115 | * |
| 115 | 116 | * @since 2.05.06 |
| 116 | 117 | * |
| 117 | 118 | * @param string $value |
| 119 | + * | |
| 120 | + * @return mixed | |
| 118 | 121 | */ |
| 119 | 122 | public function get_field_option( $value ) { |
| 120 | 123 | return FrmField::get_option( $this->field, $value ); |
| 121 | 124 | } |
| @@ -123,8 +126,10 @@ | ||
| 123 | 126 | /** |
| 124 | 127 | * @since 4.03 |
| 125 | 128 | * |
| 126 | 129 | * @param string $option |
| 130 | + * | |
| 131 | + * @return mixed | |
| 127 | 132 | */ |
| 128 | 133 | public function get_field_attr( $option ) { |
| 129 | 134 | return is_object( $this->field ) ? $this->field->{$option} : ''; |
| 130 | 135 | } |
| @@ -141,8 +146,10 @@ | ||
| 141 | 146 | /** |
| 142 | 147 | * Get the field property's label |
| 143 | 148 | * |
| 144 | 149 | * @since 2.04 |
| 150 | + * | |
| 151 | + * @return string | |
| 145 | 152 | */ |
| 146 | 153 | public function get_field_label() { |
| 147 | 154 | return $this->get_field_attr( 'name' ); |
| 148 | 155 | } |
| @@ -150,8 +157,10 @@ | ||
| 150 | 157 | /** |
| 151 | 158 | * Get the field property's id |
| 152 | 159 | * |
| 153 | 160 | * @since 2.05 |
| 161 | + * | |
| 162 | + * @return string | |
| 154 | 163 | */ |
| 155 | 164 | public function get_field_id() { |
| 156 | 165 | return $this->get_field_attr( 'id' ); |
| 157 | 166 | } |
| @@ -159,8 +168,10 @@ | ||
| 159 | 168 | /** |
| 160 | 169 | * Get the field property's key |
| 161 | 170 | * |
| 162 | 171 | * @since 2.04 |
| 172 | + * | |
| 173 | + * @return string | |
| 163 | 174 | */ |
| 164 | 175 | public function get_field_key() { |
| 165 | 176 | return $this->get_field_attr( 'field_key' ); |
| 166 | 177 | } |
| @@ -168,8 +179,10 @@ | ||
| 168 | 179 | /** |
| 169 | 180 | * Get the field property's type |
| 170 | 181 | * |
| 171 | 182 | * @since 2.04 |
| 183 | + * | |
| 184 | + * @return string | |
| 172 | 185 | */ |
| 173 | 186 | public function get_field_type() { |
| 174 | 187 | return $this->get_field_attr( 'type' ); |
| 175 | 188 | } |
| @@ -177,8 +190,10 @@ | ||
| 177 | 190 | /** |
| 178 | 191 | * Get the saved_value property |
| 179 | 192 | * |
| 180 | 193 | * @since 2.04 |
| 194 | + * | |
| 195 | + * @return mixed | |
| 181 | 196 | */ |
| 182 | 197 | public function get_saved_value() { |
| 183 | 198 | return $this->saved_value; |
| 184 | 199 | } |
| @@ -186,8 +201,10 @@ | ||
| 186 | 201 | /** |
| 187 | 202 | * Get the displayed_value property |
| 188 | 203 | * |
| 189 | 204 | * @since 2.04 |
| 205 | + * | |
| 206 | + * @return mixed | |
| 190 | 207 | */ |
| 191 | 208 | public function get_displayed_value() { |
| 192 | 209 | if ( $this->displayed_value === 'frm_not_prepared' ) { |
| 193 | 210 | return __( 'The display value has not been prepared. Please use the prepare_display_value() method before calling get_displayed_value().', 'formidable' ); |
| @@ -205,13 +222,14 @@ | ||
| 205 | 222 | * |
| 206 | 223 | * @return void |
| 207 | 224 | */ |
| 208 | 225 | protected function generate_displayed_value_for_field_type( $atts ) { |
| 209 | - if ( ! FrmAppHelper::is_empty_value( $this->displayed_value, '' ) ) { | |
| 210 | - $field_obj = FrmFieldFactory::get_field_object( $this->field ); | |
| 226 | + if ( FrmAppHelper::is_empty_value( $this->displayed_value, '' ) ) { | |
| 227 | + return; | |
| 228 | + } | |
| 211 | 229 | |
| 212 | - $this->displayed_value = $field_obj->get_display_value( $this->displayed_value, $atts ); | |
| 213 | - } | |
| 230 | + $field_obj = FrmFieldFactory::get_field_object( $this->field ); | |
| 231 | + $this->displayed_value = $field_obj->get_display_value( $this->displayed_value, $atts ); | |
| 214 | 232 | } |
| 215 | 233 | |
| 216 | 234 | /** |
| 217 | 235 | * Filter the displayed_value property |
| @@ -224,8 +242,9 @@ | ||
| 224 | 242 | */ |
| 225 | 243 | protected function filter_displayed_value( $atts ) { |
| 226 | 244 | if ( ! is_object( $this->entry ) || empty( $this->entry->metas ) ) { |
| 227 | 245 | $this->entry = FrmEntry::getOne( $this->entry_id, true ); |
| 246 | + | |
| 228 | 247 | if ( ! is_object( $this->entry ) ) { |
| 229 | 248 | return; |
| 230 | 249 | } |
| 231 | 250 | } |
| @@ -250,16 +269,18 @@ | ||
| 250 | 269 | * |
| 251 | 270 | * @return void |
| 252 | 271 | */ |
| 253 | 272 | protected function clean_saved_value() { |
| 254 | - if ( $this->saved_value !== '' ) { | |
| 255 | - if ( ! is_array( $this->saved_value ) && ! is_object( $this->saved_value ) ) { | |
| 256 | - $field_type = FrmField::get_field_type( $this->field ); | |
| 257 | - FrmFieldsHelper::prepare_field_value( $this->saved_value, $field_type ); | |
| 258 | - } | |
| 273 | + if ( $this->saved_value === '' ) { | |
| 274 | + return; | |
| 275 | + } | |
| 259 | 276 | |
| 260 | - if ( is_array( $this->saved_value ) && empty( $this->saved_value ) ) { | |
| 261 | - $this->saved_value = ''; | |
| 262 | - } | |
| 277 | + if ( ! is_array( $this->saved_value ) && ! is_object( $this->saved_value ) ) { | |
| 278 | + $field_type = FrmField::get_field_type( $this->field ); | |
| 279 | + FrmFieldsHelper::prepare_field_value( $this->saved_value, $field_type ); | |
| 280 | + } | |
| 281 | + | |
| 282 | + if ( is_array( $this->saved_value ) && ! $this->saved_value ) { | |
| 283 | + $this->saved_value = ''; | |
| 263 | 284 | } |
| 264 | 285 | } |
| 265 | 286 | } |