Fix et2-select widgets in template did not validate

This commit is contained in:
nathan 2022-07-15 12:48:25 -06:00
parent 2571d90691
commit 5793b462ba
2 changed files with 10 additions and 5 deletions
api/src/Etemplate

View File

@ -420,7 +420,8 @@ class Widget
if (!isset($class_name)) if (!isset($class_name))
{ {
list($basetype) = explode('-',$type); $exploded = explode('-', $type);
$basetype = $exploded[0] == "et2" ? $exploded[1] : $exploded[0];
if(//dont think this is used: !class_exists($class_name = 'etemplate_widget_'.str_replace('-','_',$type)) && if(//dont think this is used: !class_exists($class_name = 'etemplate_widget_'.str_replace('-','_',$type)) &&
!class_exists($class_name = __CLASS__ . '\\' . ucfirst($basetype)) && !class_exists($class_name = __CLASS__ . '\\' . ucfirst($basetype)) &&
// widgets supplied by application in class ${app}_widget_etemplate or ${app}_${subtype}_widget_etemplate // widgets supplied by application in class ${app}_widget_etemplate or ${app}_${subtype}_widget_etemplate

View File

@ -560,6 +560,10 @@ class Select extends Etemplate\Widget
{ {
$widget = $widget_type; $widget = $widget_type;
$widget_type = $widget->attrs['type'] ? $widget->attrs['type'] : $widget->type; $widget_type = $widget->attrs['type'] ? $widget->attrs['type'] : $widget->type;
if(str_starts_with($widget_type, 'et2-'))
{
$widget_type = str_replace('et2-', '', $widget_type);
}
} }
// Legacy / static support // Legacy / static support
// Have to do this explicitly, since legacy options is not defined on class level // Have to do this explicitly, since legacy options is not defined on class level