Browse Source

intruduce custom form type to reference a form template

master
Dom SP 3 years ago
parent
commit
757bfd37a0
2 changed files with 27 additions and 10 deletions
  1. +23
    -10
      app/modules/filesinfolders.php
  2. +4
    -0
      app/views/form.htm

+ 23
- 10
app/modules/filesinfolders.php View File

? $this->config['includeTemplates'] ? $this->config['includeTemplates']
: $f3->get('includeTemplates') ? : FALSE : $f3->get('includeTemplates') ? : FALSE
; ;
foreach($this->structs[$domain_key]['tpl'] as $key=>$file) {
$str = \Template::instance()->render(substr($file,7));
$str = self::linkify($str);
$this->content[$domain][$key."00tpl"] = sprintf(
"<div class=\"item %s %s\">%s</div>",
$page,
$key,
$str
);
if ($includeTemplates) {
foreach($this->structs[$domain_key]['tpl'] as $key=>$file) {
$str = \Template::instance()->render(substr($file,7));
$str = self::linkify($str);
$this->content[$domain][$key."00tpl"] = sprintf(
"<div class=\"item %s %s\">%s</div>",
$page,
$key,
$str
);
}
} }
$bulkIncludePic = array_key_exists('bulkIncludePic',$this->config) $bulkIncludePic = array_key_exists('bulkIncludePic',$this->config)
? $this->config['bulkIncludePic'] ? $this->config['bulkIncludePic']
$token = md5($timestamp . $form_config_file . rand(100,999)); $token = md5($timestamp . $form_config_file . rand(100,999));
$f3->config($form_config_file); $f3->config($form_config_file);
$fields = $f3->get('fields');
foreach ($fields as $k => $v) {
if ($v['type'] == 'custom') {
$fields[$k]['template'] = sprintf(
"%s%s",
substr($this->folder,8), //assumens content folder is content
$v['template']
);
}
}

$f3->set('fields', $f3->set('fields',
array_merge( array_merge(
$f3->get('fields'),
$fields,
['xss-token'=>[ ['xss-token'=>[
'type'=>'hidden', 'type'=>'hidden',
'value'=>$token, 'value'=>$token,

+ 4
- 0
app/views/form.htm View File

<br> <br>
</true> </true>
</check> </check>

<check if="{{ @info.type == 'custom' }}">
<include href="{{ @info.template }}" with="elements={{ @info.el }},parent={{ @name }},options={{ @info.options }}" />
</check>
</repeat> </repeat>
<button type="submit" >{{ @submit_text ? : 'save' }}</button> <button type="submit" >{{ @submit_text ? : 'save' }}</button>

Loading…
Cancel
Save