Add APP_NAME constant

Improved issue display
Add component::prepend
Add switches to form html
Updated form html to Bootstrap 5.
Updated navigation html to Bootstrap 5.
This commit is contained in:
Joey Kimsey
2025-01-21 20:46:13 -05:00
parent d9e61d3f8f
commit 61589b35ff
6 changed files with 84 additions and 29 deletions

View File

@ -11,6 +11,7 @@
*/
namespace TheTempusProject\Houdini\Classes;
use TheTempusProject\Canary\Bin\Canary as Debug;
use DateTimeZone;
class Forms {
@ -66,6 +67,9 @@ class Forms {
case 'checkbox':
$fieldHtml = self::getCheckboxHtml( $fieldname, $defaultValue );
break;
case 'switch':
$fieldHtml = self::getSwitchHtml( $fieldname, $defaultValue );
break;
case 'timezone':
$fieldHtml = self::getTimezoneHtml( $defaultValue );
break;
@ -76,19 +80,18 @@ class Forms {
Debug::error( "unknown field type: $type" );
break;
}
$out .= '<div class="form-group">';
$out .= '<label for="' . $fieldname . '" class="col-lg-3 control-label">' . $fieldTitle . '</label>';
$out .= '<div class="col-lg-3">';
$out .= '<div class="mb-3">';
$out .= '<label for="' . $fieldname . '" class="form-label">' . $fieldTitle . '</label>';
$out .= $fieldHtml;
$out .= '</div>';
// @todo need to remove this or make it more generic (can't depend on bedrock anymore)
if ( 'file' === $type ) {
$out .= '<div class="col-lg-3 avatar-125" align="center">';
$out .= '<img alt="User Avatar" src="' . $defaultValue . '" class="img-circle img-responsive">';
$out .= '<img alt="User Avatar" src="{ROOT_URL}' . $defaultValue . '" class="img-circle img-fluid p-2">';
$out .= '</div>';
}
$out .= '</div>';
return $out;
return Template::parse( $out );
}
public static function getTimezoneHtml( $default ) {
@ -117,7 +120,8 @@ class Forms {
} else {
$checked = '';
}
return '<input type="checkbox" class="form-control" name="' . $name . '" id="' . $name . '" value="true"' . $checked . '>';
return '<div class="form-check"><input class="form-check-input" type="checkbox" value="true" name="' . $name . '" id="' . $name . '"' . $checked . '>
<label class="form-check-label" for="' . $name . '">' . ucfirst($name) . '</label></div>';
}
public static function getTextHtml( $name, $default = '' ) {
@ -133,7 +137,8 @@ class Forms {
public static function getSelectHtml( $name, $options, $default = null ) {
$out = '<select name="' . $name . '" id="' . $name . '" class="form-control">';
if ( !is_string( $options ) ) {
if ( is_iterable( $options ) ) {
$out .= self::getOptionsHtml( $options, $default );
} else {
$out .= $options;
@ -190,4 +195,17 @@ class Forms {
</fieldset>';
return $out;
}
public static function getSwitchHtml( $name, $default = null ) {
$checked = '';
if ( ! empty( $default ) ) {
$checked = ' checked="checked"';
}
$out = '<div class="mb-3 form-check form-switch">
<input class="form-check-input" type="checkbox" role="switch" name="' . $name . '" id="' . $name . '" value="true"' . $checked . '>
</div>';
return $out;
}
}