| @@ 107-118 (lines=12) @@ | ||
| 104 | * @param array $input Array of field names and values. |
|
| 105 | * @return Field $this |
|
| 106 | */ |
|
| 107 | public function set_value_from_input( $input ) { |
|
| 108 | if ( ! isset( $input[ $this->name ] ) ) { |
|
| 109 | $this->set_value( array() ); |
|
| 110 | } else { |
|
| 111 | $value = stripslashes_deep( $input[ $this->name ] ); |
|
| 112 | if ( is_array( $value ) ) { |
|
| 113 | $value = array_values( $value ); |
|
| 114 | } |
|
| 115 | $this->set_value( $value ); |
|
| 116 | } |
|
| 117 | return $this; |
|
| 118 | } |
|
| 119 | ||
| 120 | /** |
|
| 121 | * Converts the field values into a usable associative array. |
|
| @@ 55-66 (lines=12) @@ | ||
| 52 | * @param array $input Array of field names and values. |
|
| 53 | * @return Field $this |
|
| 54 | */ |
|
| 55 | public function set_value_from_input( $input ) { |
|
| 56 | if ( ! isset( $input[ $this->name ] ) ) { |
|
| 57 | $this->set_value( array() ); |
|
| 58 | } else { |
|
| 59 | $value = stripslashes_deep( $input[ $this->name ] ); |
|
| 60 | if ( is_array( $value ) ) { |
|
| 61 | $value = array_values( $value ); |
|
| 62 | } |
|
| 63 | $this->set_value( $value ); |
|
| 64 | } |
|
| 65 | return $this; |
|
| 66 | } |
|
| 67 | ||
| 68 | /** |
|
| 69 | * Returns an array that holds the field data, suitable for JSON representation. |
|