@@ 696-709 (lines=14) @@ | ||
693 | * @param array $attribs Array of additional attributes |
|
694 | * @return string Raw HTML |
|
695 | */ |
|
696 | public static function check( $name, $checked = false, array $attribs = [] ) { |
|
697 | if ( isset( $attribs['value'] ) ) { |
|
698 | $value = $attribs['value']; |
|
699 | unset( $attribs['value'] ); |
|
700 | } else { |
|
701 | $value = 1; |
|
702 | } |
|
703 | ||
704 | if ( $checked ) { |
|
705 | $attribs[] = 'checked'; |
|
706 | } |
|
707 | ||
708 | return self::input( $name, $value, 'checkbox', $attribs ); |
|
709 | } |
|
710 | ||
711 | /** |
|
712 | * Convenience function to produce a radio button (input element with type=radio) |
|
@@ 719-732 (lines=14) @@ | ||
716 | * @param array $attribs Array of additional attributes |
|
717 | * @return string Raw HTML |
|
718 | */ |
|
719 | public static function radio( $name, $checked = false, array $attribs = [] ) { |
|
720 | if ( isset( $attribs['value'] ) ) { |
|
721 | $value = $attribs['value']; |
|
722 | unset( $attribs['value'] ); |
|
723 | } else { |
|
724 | $value = 1; |
|
725 | } |
|
726 | ||
727 | if ( $checked ) { |
|
728 | $attribs[] = 'checked'; |
|
729 | } |
|
730 | ||
731 | return self::input( $name, $value, 'radio', $attribs ); |
|
732 | } |
|
733 | ||
734 | /** |
|
735 | * Convenience function for generating a label for inputs. |