Пример #1
0
 /**
  * @param array $schema
  * @param bool  $returnHtml If true, HTML is returned, otherwise an array of fields
  *
  * @return string
  */
 protected static function _buildFormFields($schema, $returnHtml = true)
 {
     $_form = null;
     $_fields = array();
     foreach ($schema as $_field => $_settings) {
         //	No private fields are ever rendered
         if (false !== Option::get($_settings, 'private', false)) {
             continue;
         }
         $_value = Option::get($_settings, 'value', Option::get($_settings, 'default'));
         $_label = Option::get($_settings, 'label', Inflector::display($_field));
         $_labelAttributes = Option::get($_settings, 'label_attributes', array('for' => $_field));
         $_attributes = array_merge(array('name' => $_field, 'id' => $_field), Option::get($_settings, 'attributes', array()));
         if (false !== ($_required = Option::get($_settings, 'required', false))) {
             $_attributes['class'] = HtmlMarkup::addValue(Option::get($_attributes, 'class'), 'required');
         }
         $_form .= HtmlMarkup::label($_labelAttributes, $_label);
         $_fields[$_field]['label'] = array('value' => $_label, 'attributes' => $_labelAttributes);
         switch ($_settings['type']) {
             case 'text':
                 $_form .= HtmlMarkup::tag('textarea', $_attributes, $_value) . PHP_EOL;
                 $_fields[$_field] = array_merge($_fields[$_field], array('type' => 'textarea', 'contents' => $_value), $_attributes);
                 break;
             case 'select':
                 $_attributes['size'] = Option::get($_settings, 'size', 1);
                 $_attributes['value'] = $_value;
                 $_fields[$_field] = array_merge($_fields[$_field], array('type' => 'select', 'data' => Option::get($_settings, 'options', array())), $_attributes);
                 $_form .= HtmlMarkup::select($_fields[$_field]['data'], $_attributes) . PHP_EOL;
                 break;
             default:
                 $_attributes['maxlength'] = Option::get($_settings, 'length');
                 $_attributes['value'] = $_value;
                 $_attributes['type'] = 'text';
                 $_fields[$_field] = array_merge($_fields[$_field], array('type' => 'input', 'value' => $_value), $_attributes);
                 $_form .= HtmlMarkup::tag('input', $_attributes, null, true, true) . PHP_EOL;
                 break;
         }
     }
     return $returnHtml ? $_form : $_fields;
 }
Пример #2
0
        $_apps .= HtmlMarkup::tag('option', $_attributes, $_model->name);
        unset($_model);
    }
    unset($_models);
}
$_models = ResourceStore::model('provider')->findAll(array('select' => 'id, provider_name, api_name', 'order' => 'provider_name'));
if (!empty($_models)) {
    $_first = true;
    /** @var Provider[] $_models */
    foreach ($_models as $_model) {
        $_attributes = array('name' => $_model->api_name, 'value' => $_model->api_name, 'data-provider-id' => $_model->id, 'data-provider-tag' => Inflector::neutralize($_model->provider_name) . ':' . $_model->api_name, 'data-profile-resource' => strtolower($_model->provider_name) == 'facebook' ? '/me' : '/user');
        if ($_first) {
            $_attributes['selected'] = 'selected';
            $_first = false;
        }
        $_providers .= HtmlMarkup::tag('option', $_attributes, $_model->api_name . ' (' . Inflector::display($_model->provider_name) . ')');
        $_providerCache->{$_model->api_name} = $_model->getAttributes();
        unset($_model, $_config, $_attributes, $_profileResource);
    }
    unset($_models);
}
//	Default url
$_defaultUrl = '/rest/system/user';
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <title>DreamFactory Portal Sandbox</title>
    <meta charset="utf-8" />
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />