$callable, 'options' => $options, ); } public static function render($field, SimpleConfig $simpleConfigPreset) { if(self::$register === null) { self::init(); } if(!isset(self::$register[$field['type']])) { return 'Field type "'.$field['type'].'" not found'; } $origName = $field['name']; $field['name'] = $origName.'[value]'; if(!empty($field['repeatable'])) { $field['name'] .= '[]'; } if(isset($field['value']) && is_array($field['value'])) { $field['mode'] = $field['value']['mode']; $field['value'] = $field['value']['value']; } if(empty($field['mode'])) { $field['mode'] = 'default'; } if(self::$register[$field['type']]['options']['decorated'] == false) { $switchButton = ''; $fieldId = 'fid'.md5(microtime().rand(100000,999999)); if(self::$register[$field['type']]['options']['customvalue'] == true) { $switchButton = ''; } $helpButton = ''; if(!empty($field['help'])) { $helpButton = '  '; } if(empty($field['fullwidth'])) { $html = ''.$field['label'].$helpButton.$switchButton.''; } else { $html = ''.$field['label'].$helpButton.$switchButton.''; } if(!empty($field['repeatable'])) { if(!is_array($field['value']) || empty($field['value'])) { $field['value'] = array(''); } $allValues = $field['value']; for($i = 0; $i < count($allValues);$i++) { $field['value'] = $allValues[$i]; $html .= self::_renderInternal($fieldId, $field, $origName); } } else { $html .= self::_renderInternal($fieldId, $field, $origName); } if(!empty($field['description'])) { $html .= ''.$field['description'].''; } $html .= ''; } else { $html = call_user_func(self::$register[$field['type']]['call'], $field); } return $html; } private static function _renderInternal($fieldId, $field, $origName) { $html = '
'; if (self::$register[$field['type']]['options']['customvalue'] == true) { $html .= ''; if ($field['mode'] == 'default') { $field['disabled'] = true; } $html .= '
' . call_user_func(self::$register['customconfigfield']['call'], $field) . '
'; unset($field['disabled']); } $html .= '
' . call_user_func(self::$register[$field['type']]['call'], $field) . '
'; if (!empty($field['repeatable'])) { $html .= ''; } $html .= '
'; return $html; } }