本文整理汇总了PHP中HTML_QuickForm2_Renderer类的典型用法代码示例。如果您正苦于以下问题:PHP HTML_QuickForm2_Renderer类的具体用法?PHP HTML_QuickForm2_Renderer怎么用?PHP HTML_QuickForm2_Renderer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HTML_QuickForm2_Renderer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
public function render(HTML_QuickForm2_Renderer $renderer)
{
if (method_exists($renderer->getJavascriptBuilder(), 'addValidateJs')) {
$renderer->getJavascriptBuilder()->addValidateJs('errorElement: "span"');
}
return parent::render($renderer);
}
示例2: createForm
function createForm($form)
{
HTML_QuickForm2_Renderer::register('smarty', 'HTML_QuickForm2_Renderer_Smarty');
$renderer = HTML_QuickForm2_Renderer::factory('smarty');
$renderer->setOption('old_compat', true);
$renderer->setOption('group_errors', true);
// フォームの作成
$FormData = $form->render($renderer)->toArray();
$this->smarty->assign('form', $FormData);
$this->smarty->display('login.html');
}
示例3: testGroupHiddens
public function testGroupHiddens()
{
$form = new HTML_QuickForm2('testGroupHiddens', 'post', null, false);
$hidden = $form->addHidden('aHiddenElement');
$renderer = HTML_QuickForm2_Renderer::factory('stub');
$renderer->setOption('group_hiddens', false);
$form->render($renderer);
$this->assertEquals(array(), $renderer->getHidden());
$renderer->setOption('group_hiddens', true);
$form->render($renderer);
$this->assertEquals(array($hidden->__toString()), $renderer->getHidden());
}
示例4: createForm
function createForm($form, $add_data = NULL)
{
// smartyインスタンス作成
$smarty = $this->getSmarty();
HTML_QuickForm2_Renderer::register('smarty', 'HTML_QuickForm2_Renderer_Smarty');
$renderer = HTML_QuickForm2_Renderer::factory('smarty');
$renderer->setOption('old_compat', true);
// フォームの作成
$FormData = $form->render($renderer)->toArray();
$smarty->assign('data', $add_data);
$smarty->assign('form', $FormData);
$smarty->display('search.html');
}
示例5: renderForm
function renderForm($addHidden)
{
$this->initPossibleConditions();
$t = new Am_View();
$renderer = HTML_QuickForm2_Renderer::factory('array');
if (!$this->form) {
$this->createForm(array());
}
$this->form->render($renderer);
$t->assign('form', $renderer->toArray());
$t->assign('description', $this->getDescription(true));
$t->assign('serialized', $this->serialize());
$t->assign('hidden', $addHidden);
$t->assign('loadSearchOptions', Am_Controller::renderOptions($this->getLoadOptions(), $this->saved_search_id));
return $t->render($this->template);
}
示例6: render
public function render(HTML_QuickForm2_Renderer $renderer)
{
// render as a normal select when frozen
if ($this->frozen) {
$renderer->renderElement($this);
} else {
$jsBuilder = $renderer->getJavascriptBuilder();
$this->renderClientRules($jsBuilder);
$jsBuilder->addLibrary('dualselect', 'dualselect.js', 'js/', dirname(__FILE__) . DIRECTORY_SEPARATOR . 'js' . DIRECTORY_SEPARATOR);
$keepSorted = empty($this->data['keepSorted']) ? 'false' : 'true';
$jsBuilder->addElementJavascript("qf.elements.dualselect.init('{$this->getId()}', {$keepSorted});");
// Fall back to using the Default renderer if custom one does not have a plugin
if ($renderer->methodExists('renderDualSelect')) {
$renderer->renderDualSelect($this);
} else {
$renderer->renderElement($this);
}
}
return $renderer;
}
示例7: render
/**
* This element is rendered using renderHidden() method
*
* renderHidden() is used to
* - prevent using the standard element template as this button is
* expected to be hidden
* - render it above all other submit buttons since hidden elements
* are usually at the top of the form
*
* @param HTML_QuickForm2_Renderer Renderer instance
* @return HTML_QuickForm2_Renderer
*/
public function render(HTML_QuickForm2_Renderer $renderer)
{
$renderer->renderHidden($this);
return $renderer;
}
示例8: report_error
}
}
$row = package::info((int) $_GET['id']);
if (empty($row['name'])) {
report_error('Illegal package id');
response_footer();
exit;
}
print_package_navigation($row['packageid'], $row['name'], '/package-edit.php?id=' . $row['packageid']);
$sth = $dbh->query('SELECT id, name FROM categories ORDER BY name');
while ($cat_row = $sth->fetchRow(DB_FETCHMODE_ASSOC)) {
$rows[$cat_row['id']] = $cat_row['name'];
}
$form = new HTML_QuickForm2('package-edit', 'post', array('action' => '/package-edit.php?id=' . $row['packageid']));
$form->removeAttribute('name');
$renderer = HTML_QuickForm2_Renderer::factory('default');
// Set defaults for the form elements
$form->addDataSource(new HTML_QuickForm2_DataSource_Array(array('name' => htmlspecialchars($row['name']), 'license' => htmlspecialchars($row['license']), 'summary' => htmlspecialchars($row['summary']), 'description' => htmlspecialchars($row['description']), 'category' => (int) $row['categoryid'], 'homepage' => htmlspecialchars($row['homepage']), 'doc_link' => htmlspecialchars($row['doc_link']), 'bug_link' => htmlspecialchars($row['bug_link']), 'cvs_link' => htmlspecialchars($row['cvs_link']), 'unmaintained' => $row['unmaintained'] ? true : false, 'newpk_id' => (int) $row['newpk_id'], 'new_channel' => htmlspecialchars($row['new_channel']), 'new_package' => htmlspecialchars($row['new_package']))));
$form->addElement('text', 'name', array('maxlength' => "80", 'accesskey' => "c"))->setLabel('Pa<span class="accesskey">c</span>kage Name');
$form->addElement('text', 'license', array('maxlength' => "50", 'placeholder' => 'BSD'))->setLabel('License:');
$form->addElement('textarea', 'summary', array('cols' => "75", 'rows' => "7", 'maxlength' => "255"))->setLabel('Summary');
$form->addElement('textarea', 'description', array('cols' => "75", 'rows' => "12"))->setLabel('Description');
$form->addElement('select', 'category')->setLabel('Category:')->loadOptions($rows);
$manager = new Tags_Manager();
$sl = $form->addElement('select', 'tags', array('multiple' => 'multiple'))->setLabel('Tags:')->loadOptions(array('' => '(none)') + $manager->getTags(false, true));
$sl->setValue(array_keys($manager->getTags($row['name'], true)));
$form->addElement('text', 'homepage', array('maxlength' => 255, 'accesskey' => "O"))->setLabel('H<span class="accesskey">o</span>mepage:');
$form->addElement('text', 'doc_link', array('maxlength' => 255, 'placeholder' => 'http://example.com/manual'))->setLabel('Documentation URI:');
$form->addElement('url', 'bug_link', array('maxlength' => 255, 'placeholder' => 'http://example.com/bugs'))->setLabel('Bug Tracker URI:');
$form->addElement('url', 'cvs_link', array('maxlength' => 255, 'placeholder' => 'http://example.com/svn/trunk'))->setLabel('Web version control URI');
$form->addElement('checkbox', 'unmaintained')->setLabel('Is this package unmaintained ?');
示例9: str_replace
if ($debugEnable) {
$form->removeChild($buttons);
// Remove buttons.
$form->toggleFrozen(true);
// Freeze the form for display.
$mainTextHTML .= "<a title='Vidare' href='?p={$redirect}'>\n <img src='images/accept.png' alt='Vidare' /></a> <br />\r\n";
} else {
$redirect = str_replace("&", "&", $redirect);
header('Location: ' . WS_SITELINK . "?p={$redirect}");
exit;
}
}
/*
* If the form is incorrect filled it is displayed again with comments.
*/
$renderer = HTML_QuickForm2_Renderer::factory('default')->setOption(array('group_hiddens' => true, 'group_errors' => true, 'errors_prefix' => 'Följand information saknas eller är felaktigt ifylld:', 'errors_suffix' => '', 'required_note' => 'Obligatoriska fält är markerade med <em>*</em>'))->setTemplateForId('submit', '<div class="element">{element} or <a href="/">Cancel</a></div>');
$form->render($renderer);
$mainTextHTML .= "<h3>Formulär för att skapa ett nytt album eller editera ett \n gammalt.</h3><br />\r\n" . $renderer;
/*
* Add all thumbs in the album, if there are any, with possibility to
* chose signature picture.
*/
$query = "\n SELECT idPicture FROM {$tablePicture} \n WHERE picture_idAlbum = {$idAlbum};\n";
if ($idAlbum and $result = $dbAccess->SingleQuery($query)) {
$mainTextHTML .= "<h3>Välj signaturbild för albumet</h3>";
while ($row = $result->fetch_object()) {
$mainTextHTML .= "<a href='?p=sign_pict&album=" . $idAlbum . "&pict=" . $row->idPicture . "'>\n <img src='" . WS_PICTUREARCHIVE . PA_THUMBPREFIX . $row->idPicture . ".jpg' />\n </a>";
}
$result->close();
}
/*
示例10: render
public function render(HTML_QuickForm2_Renderer $renderer)
{
$renderer->getJavascriptBuilder()->addElementJavascript($this->getJs());
return parent::render($renderer);
}
示例11: edit
/**
* edit edits the given entry
*
* @param int $cid entry-id for calendar
* @return string html-string
*/
private function edit($cid)
{
// check rights
if (Rights::check_rights($cid, 'calendar')) {
// smarty-templates
$sD = new JudoIntranetSmarty();
// get calendar-object
$calendar = new Calendar($cid);
// pagecaption
$this->tpl->assign('pagecaption', parent::lang('class.CalendarView#page#caption#edit') . ": \"{$cid}\" (" . $calendar->get_name() . ")");
// get rights
$cRights = $calendar->get_rights()->get_rights();
// check public access
$kPublicAccess = array_search(0, $cRights);
$publicAccess = false;
if ($kPublicAccess !== false) {
$publicAccess = true;
unset($cRights[$kPublicAccess]);
}
// prepare return
$return = '';
$form = new HTML_QuickForm2('edit_calendar_entry', 'post', array('name' => 'edit_calendar_entry', 'action' => 'calendar.php?id=edit&cid=' . $cid));
$now_year = (int) date('Y');
$year_min = $now_year;
$year_max = $now_year + 3;
// get datasource
$datasource = array('date' => $calendar->get_date(), 'name' => $calendar->get_name(), 'shortname' => $calendar->get_shortname(), 'type' => $calendar->return_type(), 'entry_content' => $calendar->get_content(), 'rights' => $cRights);
// add public access
if ($publicAccess) {
$datasource['public'] = 1;
}
$form->addDataSource(new HTML_QuickForm2_DataSource_Array($datasource));
// renderer
$renderer = HTML_QuickForm2_Renderer::factory('default');
$renderer->setOption('required_note', parent::lang('class.CalendarView#entry#form#requiredNote'));
// elements
// date
$date = $form->addElement('text', 'date', array());
$date->setLabel(parent::lang('class.CalendarView#entry#form#date') . ':');
// rule
$date->addRule('required', parent::lang('class.CalendarView#entry#rule#required.date'));
$date->addRule('callback', parent::lang('class.CalendarView#entry#rule#check.date'), array($this, 'callback_check_date'));
// add jquery-datepicker
// smarty
$sD->assign('elementid', 'date-0');
$sD->assign('dateFormat', 'yy-mm-dd');
$sD->assign('dateValue', $calendar->get_date());
$this->add_jquery($sD->fetch('smarty.js-datepicker.tpl'));
// name
$name = $form->addElement('text', 'name');
$name->setLabel(parent::lang('class.CalendarView#entry#form#name') . ':');
$name->addRule('required', parent::lang('class.CalendarView#entry#rule#required.name'));
$name->addRule('regex', parent::lang('class.CalendarView#entry#rule#regexp.allowedChars') . ' [' . $_SESSION['GC']->get_config('name.desc') . ']', $_SESSION['GC']->get_config('name.regexp'));
// shortname
$shortname = $form->addElement('text', 'shortname');
$shortname->setLabel(parent::lang('class.CalendarView#entry#form#shortname') . ':');
$shortname->addRule('regex', parent::lang('class.CalendarView#entry#rule#regexp.allowedChars') . ' [' . $_SESSION['GC']->get_config('name.desc') . ']', $_SESSION['GC']->get_config('name.regexp'));
// type
$options = array_merge(array(0 => '--'), Calendar::return_types());
$type = $form->addElement('select', 'type');
$type->setLabel(parent::lang('class.CalendarView#entry#form#type') . ':');
$type->loadOptions($options);
$type->addRule('required', parent::lang('class.CalendarView#entry#rule#required.type'));
$type->addRule('callback', parent::lang('class.CalendarView#entry#rule#check.select'), array($this, 'callback_check_select'));
// entry_content
$content = $form->addElement('textarea', 'entry_content');
$content->setLabel(parent::lang('class.CalendarView#entry#form#entry_content') . ':');
$content->addRule('regex', parent::lang('class.CalendarView#entry#rule#regexp.allowedChars') . ' [' . $_SESSION['GC']->get_config('textarea.desc') . ']', $_SESSION['GC']->get_config('textarea.regexp'));
// select rights
$options = $_SESSION['user']->return_all_groups('sort');
$rights = $form->addElement('select', 'rights', array('multiple' => 'multiple', 'size' => 5));
$rights->setLabel(parent::lang('class.CalendarView#entry#form#rights') . ':');
$rights->loadOptions($options);
// checkbox public
$rights = $form->addElement('checkbox', 'public');
$rights->setLabel(parent::lang('class.CalendarView#entry#form#public') . ':');
// submit-button
$form->addElement('submit', 'submit', array('value' => parent::lang('class.CalendarView#entry#form#submitButton')));
// validate
if ($form->validate()) {
// create calendar-object
$data = $form->getValue();
// check $data['rights']
if (!isset($data['rights'])) {
$data['rights'] = array();
}
// merge with own groups, add admin
$data['rights'] = array_merge($data['rights'], $_SESSION['user']->get_groups(), array(1));
// add public access
$kPublicAccess = array_search(0, $data['rights']);
if ($kPublicAccess === false && isset($data['public']) && $data['public'] == 1) {
$data['rights'][] = 0;
} elseif ($kPublicAccess !== false && !isset($data['public'])) {
unset($data['rights'][$kPublicAccess]);
//.........这里部分代码省略.........
示例12: __toString
public function __toString()
{
HTML_QuickForm2_Loader::loadClass('HTML_QuickForm2_Renderer');
$renderer = $this->render(HTML_QuickForm2_Renderer::factory('default'));
return $renderer->__toString() . $renderer->getJavascriptBuilder()->getSetupCode(null, true);
}
示例13: getAssignFormRendered
protected function getAssignFormRendered()
{
$form = $this->getForm(self::FORM_ASSIGN);
$renderer = HTML_QuickForm2_Renderer::factory('array');
$form->render($renderer);
$form = $renderer->toArray();
$elements = array();
foreach ($form['elements'] as $element) {
$elements[$element['id']] = $element;
}
$form['elements'] = $elements;
return $form;
}
示例14: HTML_QuickForm2
.quickform div.errors ul { margin:0; }
.quickform div.error input { border-color: #C00; background-color: #FEF; }
.quickform div.qf-checkable label,
.quickform div.qf-checkable input { display: inline; float: none; }
.quickform div.qf-checkable div,
.quickform div.qf-message { margin-left: 170px; }
.quickform div.qf-message { font-size: 88%; color: #C00; }
</style>
<title>HTML_QuickForm2 default renderer example</title>
</head>
<body>
<?php
require_once 'HTML/QuickForm2.php';
require_once 'HTML/QuickForm2/Renderer.php';
$form = new HTML_QuickForm2('example');
$fs = $form->addFieldset()->setLabel('Your information');
$username = $fs->addText('username')->setLabel('Username');
$username->addRule('required', 'Username is required');
$password = $fs->addPassword('pass')->setLabel(array('Password', 'Password should be 8 characters at minimum'));
$password->addRule('required', 'Password is required');
$form->addHidden('my_hidden1')->setValue('1');
$form->addHidden('my_hidden2')->setValue('2');
$form->addSubmit('submit', array('value' => 'Send', 'id' => 'submit'));
if ($form->validate()) {
$form->toggleFrozen(true);
}
$renderer = HTML_QuickForm2_Renderer::factory('default')->setOption(array('group_hiddens' => true, 'group_errors' => true, 'required_note' => '<strong>Note:</strong> Required fields are marked with an asterisk (<em>*</em>).'))->setTemplateForId('submit', '<div class="element">{element} or <a href="/">Cancel</a></div>')->setTemplateForClass('HTML_QuickForm2_Element_Input', '<div class="element<qf:error> error</qf:error>"><qf:error>{error}</qf:error>' . '<label for="{id}" class="qf-label<qf:required> required</qf:required>">{label}</label>' . '{element}' . '<qf:label_2><div class="qf-label-1">{label_2}</div></qf:label_2></div>');
echo $form->render($renderer);
?>
</body>
</html>
示例15: toString
function toString($tpl)
{
$renderer = \HTML_QuickForm2_Renderer::factory('larakit_form');
$this->render($renderer);
larajs()->addInline($renderer->getJavascriptBuilder()->getFormJavascript($this->getId(), false));
return \View::make($tpl, ['is_submited' => (bool) $this->isSubmitted(), 'form' => $renderer->toArray(), 'meta' => \Larakit\QuickForm\Register::$elements])->__toString();
}