LLMS_Form_Field::get_field_html()
Retrieve the full HTML for the field.
Return Return
(string)
Source Source
File: includes/forms/class-llms-form-field.php
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 | protected function get_field_html() { /** * Allow 3rd parties to create custom field types or their own field HTML methods. * * Returning a non-empty string will override default HTML generation and use the returned HTML instead. * * @since 5.0.0 * * @param string $html Override html. * @param array $settings Array of field settings initially passed to the class constructor. * @param LLMS_Form_Field $field Form field object. */ $override = apply_filters( 'llms_form_field_get_' . $this ->settings[ 'type' ] . '_html' , '' , $this ->settings, $this ); if ( ! empty ( $override ) ) { return $override ; } $extra_attrs = array (); $inner_html = '' ; $self_closing = false; switch ( $this ->settings[ 'type' ] ) { case 'button' : case 'reset' : case 'submit' : $tag = 'button' ; $classes = array ( 'llms-field-button' ); $inner_html = $this ->settings[ 'value' ]; $extra_attrs [ 'type' ] = $this ->settings[ 'type' ]; break ; case 'checkbox' : case 'radio' : $is_group = ! empty ( $this ->settings[ 'options' ] ); $tag = $is_group ? 'div' : 'input' ; $self_closing = ! $is_group ; $classes = array ( sprintf( 'llms-field-%s' , $this ->settings[ 'type' ] ) ); if ( ! $is_group ) { $extra_attrs [ 'type' ] = $this ->settings[ 'type' ]; if ( true === $this ->settings[ 'checked' ] ) { $extra_attrs [ 'checked' ] = 'checked' ; } } else { $classes [] = 'llms-input-group' ; $fields = $this ->explode_options_to_fields( false ); foreach ( $fields as $field ) { $inner_html .= $field ->get_html(); } } break ; case 'html' : $tag = 'div' ; $classes = array ( 'llms-field-html' ); $inner_html = $this ->settings[ 'value' ]; break ; case 'select' : $tag = 'select' ; $classes = array ( 'llms-field-select' ); $inner_html = $this ->get_options_html(); break ; case 'textarea' : $tag = 'textarea' ; $classes = array ( 'llms-field-textarea' ); $inner_html = $this ->settings[ 'value' ]; break ; default : $tag = 'input' ; $self_closing = true; $classes = array ( 'llms-field-input' ); $extra_attrs [ 'type' ] = $this ->settings[ 'type' ]; } $extra_attrs [ 'class' ] = implode( ' ' , $this ->classes_ensure_array( $this ->settings[ 'classes' ], $classes ) ); $attributes = array_merge ( $this ->get_html_attributes( $this ->settings ), $extra_attrs ); ksort( $attributes ); $attrs = '' ; foreach ( $attributes as $attr => $val ) { $attrs .= sprintf( ' %1$s="%2$s"' , $attr , $val ); } $open = $self_closing ? sprintf( '<%1$s%2$s' , $tag , $attrs ) : sprintf( '<%1$s%2$s>' , $tag , $attrs ); $close = $self_closing ? ' />' : sprintf( '</%s>' , $tag ); return sprintf( '%1$s%2$s%3$s' , $open , $inner_html , $close ); } |
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
6.2.0 | Moved exploding of checkbox and radio options to explode_options_to_fields() . |
5.0.0 | Introduced. |