This commit is contained in:
2024-04-03 06:25:04 +03:00
parent 667cf886d5
commit 0fe261d345
17 changed files with 144 additions and 46 deletions
+26
View File
@@ -0,0 +1,26 @@
<?php
/**
* @var \Wt\Core\Templater\Shell $this
* @var \Wt\Core\Form\Field\DefaultField $field
*/
use Wt\Core\Templater\Tools;
$bLabel = mb_strlen($field->getLabel());
$labelAttrs = [];
if(mb_strlen($field->getId())){
$labelAttrs['for'] = $field->getId();
}
if($bLabel){?><label <?=Tools::getAttrByArray($labelAttrs)?>><?=$field->getLabel()?></label><?}
$inputAttributes = $field->getAttributes();
$inputAttributes['data-dirty'] = $field->isDirty()?'true':'false';
if($field->isMultiple()){
$inputAttributes['name'] = preg_replace('/\[]$/', '', $inputAttributes['name']) . '[]';
}
unset($inputAttributes['options']);
?><select <?=Tools::getAttrByArray($inputAttributes)?>><?
foreach ($field->getOptions() as $key => $value){
?><option value="<?=$key?>"<?if($field->isSelectValue($key)){?> selected<?}?>><?=$value?></option><?
}
?></select><?
echo "\n\r";