@@ 121-146 (lines=26) @@ | ||
118 | * |
|
119 | * @since 2.0 |
|
120 | */ |
|
121 | public function input ( $name, $value = null, $options = null, $pod = null, $id = null ) { |
|
122 | $options = (array) $options; |
|
123 | $form_field_type = PodsForm::$field_type; |
|
124 | ||
125 | if ( is_array( $value ) ) |
|
126 | $value = implode( ' ', $value ); |
|
127 | ||
128 | $field_type = 'email'; |
|
129 | ||
130 | if ( isset( $options[ 'name' ] ) && false === PodsForm::permission( self::$type, $options[ 'name' ], $options, null, $pod, $id ) ) { |
|
131 | if ( pods_var( 'read_only', $options, false ) ) { |
|
132 | $options[ 'readonly' ] = true; |
|
133 | ||
134 | $field_type = 'text'; |
|
135 | } |
|
136 | else |
|
137 | return; |
|
138 | } |
|
139 | elseif ( !pods_has_permissions( $options ) && pods_var( 'read_only', $options, false ) ) { |
|
140 | $options[ 'readonly' ] = true; |
|
141 | ||
142 | $field_type = 'text'; |
|
143 | } |
|
144 | ||
145 | pods_view( PODS_DIR . 'ui/fields/' . $field_type . '.php', compact( array_keys( get_defined_vars() ) ) ); |
|
146 | } |
|
147 | ||
148 | /** |
|
149 | * Build regex necessary for JS validation |
@@ 146-171 (lines=26) @@ | ||
143 | * |
|
144 | * @since 2.0 |
|
145 | */ |
|
146 | public function input ( $name, $value = null, $options = null, $pod = null, $id = null ) { |
|
147 | $options = (array) $options; |
|
148 | $form_field_type = PodsForm::$field_type; |
|
149 | ||
150 | if ( is_array( $value ) ) |
|
151 | $value = implode( ' ', $value ); |
|
152 | ||
153 | $field_type = 'phone'; |
|
154 | ||
155 | if ( isset( $options[ 'name' ] ) && false === PodsForm::permission( self::$type, $options[ 'name' ], $options, null, $pod, $id ) ) { |
|
156 | if ( pods_var( 'read_only', $options, false ) ) { |
|
157 | $options[ 'readonly' ] = true; |
|
158 | ||
159 | $field_type = 'text'; |
|
160 | } |
|
161 | else |
|
162 | return; |
|
163 | } |
|
164 | elseif ( !pods_has_permissions( $options ) && pods_var( 'read_only', $options, false ) ) { |
|
165 | $options[ 'readonly' ] = true; |
|
166 | ||
167 | $field_type = 'text'; |
|
168 | } |
|
169 | ||
170 | pods_view( PODS_DIR . 'ui/fields/' . $field_type . '.php', compact( array_keys( get_defined_vars() ) ) ); |
|
171 | } |
|
172 | ||
173 | /** |
|
174 | * Validate a value before it's saved |
@@ 89-114 (lines=26) @@ | ||
86 | * |
|
87 | * @since 2.0 |
|
88 | */ |
|
89 | public function input ( $name, $value = null, $options = null, $pod = null, $id = null ) { |
|
90 | $options = (array) $options; |
|
91 | $form_field_type = PodsForm::$field_type; |
|
92 | ||
93 | if ( is_array( $value ) ) |
|
94 | $value = implode( '-', $value ); |
|
95 | ||
96 | $field_type = 'slug'; |
|
97 | ||
98 | if ( isset( $options[ 'name' ] ) && false === PodsForm::permission( self::$type, $options[ 'name' ], $options, null, $pod, $id ) ) { |
|
99 | if ( pods_var( 'read_only', $options, false ) ) { |
|
100 | $options[ 'readonly' ] = true; |
|
101 | ||
102 | $field_type = 'text'; |
|
103 | } |
|
104 | else |
|
105 | return; |
|
106 | } |
|
107 | elseif ( !pods_has_permissions( $options ) && pods_var( 'read_only', $options, false ) ) { |
|
108 | $options[ 'readonly' ] = true; |
|
109 | ||
110 | $field_type = 'text'; |
|
111 | } |
|
112 | ||
113 | pods_view( PODS_DIR . 'ui/fields/' . $field_type . '.php', compact( array_keys( get_defined_vars() ) ) ); |
|
114 | } |
|
115 | ||
116 | /** |
|
117 | * Build regex necessary for JS validation |
@@ 179-204 (lines=26) @@ | ||
176 | * |
|
177 | * @since 2.0 |
|
178 | */ |
|
179 | public function input ( $name, $value = null, $options = null, $pod = null, $id = null ) { |
|
180 | $options = (array) $options; |
|
181 | $form_field_type = PodsForm::$field_type; |
|
182 | ||
183 | if ( is_array( $value ) ) |
|
184 | $value = implode( ' ', $value ); |
|
185 | ||
186 | $field_type = 'website'; |
|
187 | ||
188 | if ( isset( $options[ 'name' ] ) && false === PodsForm::permission( self::$type, $options[ 'name' ], $options, null, $pod, $id ) ) { |
|
189 | if ( pods_var( 'read_only', $options, false ) ) { |
|
190 | $options[ 'readonly' ] = true; |
|
191 | ||
192 | $field_type = 'text'; |
|
193 | } |
|
194 | else |
|
195 | return; |
|
196 | } |
|
197 | elseif ( !pods_has_permissions( $options ) && pods_var( 'read_only', $options, false ) ) { |
|
198 | $options[ 'readonly' ] = true; |
|
199 | ||
200 | $field_type = 'text'; |
|
201 | } |
|
202 | ||
203 | pods_view( PODS_DIR . 'ui/fields/' . $field_type . '.php', compact( array_keys( get_defined_vars() ) ) ); |
|
204 | } |
|
205 | ||
206 | /** |
|
207 | * Validate a value before it's saved |