本文整理汇总了PHP中form::attributes方法的典型用法代码示例。如果您正苦于以下问题:PHP form::attributes方法的具体用法?PHP form::attributes怎么用?PHP form::attributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类form
的用法示例。
在下文中一共展示了form::attributes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: open
/**
* Generates an opening HTML form tag.
*
* @param string form action attribute
* @param array extra attributes
* @param array hidden fields to be created immediately after the form tag
* @return string
*/
public static function open($action = NULL, $attr = array(), $hidden = NULL)
{
// Make sure that the method is always set
empty($attr['method']) and $attr['method'] = 'post';
if ($attr['method'] !== 'post' and $attr['method'] !== 'get') {
// If the method is invalid, use post
$attr['method'] = 'post';
}
if ($action === NULL) {
// Use the current URL as the default action
$action = url::site(Router::$complete_uri);
} elseif (strpos($action, '://') === FALSE) {
// Make the action URI into a URL
$action = url::site($action);
}
// Set action
$attr['action'] = $action;
// Only show the CSRF field when form method is POST
$hidden_field = $attr['method'] === 'post' ? form::hidden('form_auth_token', csrf::token()) . "\n" : '';
// Form opening tag
$form = '<form' . form::attributes($attr) . '>' . "\n" . $hidden_field;
// Add hidden fields immediate after opening tag
empty($hidden) or $form .= form::hidden($hidden);
return $form;
}
示例2: render
public function render(&$render_variables, $errors = array())
{
$result = parent::render($render_variables, $errors);
// Clean attributes
$id = $this->_clean_attributes($result['attributes'], 'id');
$buffer = $this->_create_rating($result['attributes']);
$result['template']->element = $buffer;
$result['template']->attributes = form::attributes($result['attributes']);
return (string) $result['template']->render();
}
示例3: render
public function render(&$render_variables, $errors = array())
{
// Load base template and attributes
$result = parent::render($render_variables, $errors);
$result['template']->element = $this->value;
$result['attributes'] = $this->_filter_attributes(array('name'), $result['attributes']);
if ($result['attributes']) {
$result['template']->attributes = form::attributes($result['attributes']);
}
// Return the resulting output
return (string) $result['template']->render();
}
示例4: dropdown
/**
* Creates an HTML form select tag with all avaliable timezones
* Mash-up of kohana dropdowns and code retrieved from:
* http://usphp.com/manual/en/function.timezone-identifiers-list.php on 7/23/2009
* Modified by K Anderson
*
* TODO: This needs to be refactored to use the kohana html helpers
*
* @param string|array input name or an array of HTML attributes
* @param string option key that should be selected by default
* @param string a string to be attached to the end of the attributes
* @return string
*/
public static function dropdown($data, $selected = NULL, $extra = '')
{
if (!is_array($data)) {
$data = array('name' => $data);
} else {
if (isset($data['options'])) {
// Use data options
$options = $data['options'];
}
if (isset($data['selected'])) {
// Use data selected
$selected = $data['selected'];
}
}
$input = '<select' . form::attributes($data, 'select') . ' ' . $extra . '>' . "\n";
if (empty($selected)) {
$selectedzone = date_default_timezone_get();
} else {
$selectedzone = $selected;
}
$input .= self::timezonechoice($selectedzone);
$input .= '</select>';
return $input;
}
示例5: render
/**
* This function buils the HTML for a grid, you can choose to render the paging/nav bar
* and supply any additional HTML attributes for either the table of the nav div in a array
* such that the array looks like:
*
* array(
* 'table' => array ('id' => 'someID', 'class'=> 'gridTable', 'extra' => 'onclick="alert('test');"),
* 'div' => array ('style' => 'text-align: center;')
* )
*
* @return string grid HTML
* @param bool $createNavGrid[optional]
* @param array $attributes[optional]
*/
public function render($createNavGrid = true, $attributes = array())
{
/**
*
* THIS SECTION GENERATES HTML FOR A TABLE
*
*/
$html = '<div id="' . $this->gridName . 'AjaxMessageReceiver" style="display:none;"> </div>';
// If the user has not supplied an id then we will gen one for the table
if (empty($attributes['table']['id'])) {
$attributes['table']['id'] = $this->gridName;
}
// We need to add a default class to the table
$attributes['table']['class'] = empty($attributes['table']['class']) ? 'scroll jqgrid_instance' : $attributes['table']['class'] . ' scroll jqgrid_instance';
// This gets any extra attributes and unsets it so the form helper will not parse it
if (!empty($attributes['table']['extra'])) {
$extra = $attributes['table']['extra'];
unset($attributes['table']['extra']);
} else {
$extra = '';
}
// Build the HTML for the table
$html .= '<table' . form::attributes($attributes['table']) . ' ' . $extra . '><tr><td></td></tr></table>' . "\n";
/**
*
* THIS SECTION GENERATES HTML FOR A NAVIGATION DIV
*
*/
$customNavButtons = array();
$navGrid = array('options' => array(), 'edit' => array(), 'add' => array(), 'del' => array(), 'search' => array(), 'view' => array());
if ($createNavGrid) {
// If the user has not supplied an id then we will gen one for the div
if (empty($attributes['div']['id'])) {
$attributes['div']['id'] = 'pager_' . $attributes['table']['id'];
}
// We need to add a default class to the div
$attributes['div']['class'] = empty($attributes['div']['class']) ? 'scroll' : $attributes['div']['class'] . ' scroll';
// This gets any extra attributes and unsets it so the form helper will not parse it
if (!empty($attributes['div']['extra'])) {
$extra = $attributes['div']['extra'];
unset($attributes['div']['extra']);
} else {
$extra = '';
}
// Build the HTML for the div
$html .= '<div' . form::attributes($attributes['div']) . ' ' . $extra . '></div>' . "\n";
// Add the pager div ID to the grid parameters
$this->jquery['pager'] = '#' . $attributes['div']['id'];
// build the array of navGrid options, setting defaults as we go
if (isset($this->jquery['navGrid'])) {
$this->jquery['navGrid'] += $navGrid;
$navGrid = $this->jquery['navGrid'];
unset($this->jquery['navGrid']);
}
$navOptions = array('edit' => false, 'add' => false, 'del' => false, 'search' => true, 'view' => false);
$navGrid['options'] = arr::merge($navOptions, $navGrid['options']);
// build an array of navButtons
if (!empty($this->jquery['navButton'])) {
$customNavButtons = $this->jquery['navButton'];
unset($this->jquery['navButton']);
}
}
/**
*
* THIS SECTION GENERATES JS
*
*/
self::_orderColumns();
$this->jquery['colNames'] = array_values($this->query['columns']);
if (!empty($this->query['actions'])) {
// Add this column name to the jqgrid colName headers
$this->jquery['colNames'][] = '<div style="text-align:center;">' . __('Actions') . '</div>';
// A convience wraper for adding a colModel to jqgrid
$colModel =& $this->jquery['colModel'][];
// Accept any custom parameters for the action column
if (!empty($this->query['actionsColumn'])) {
$colModel = $this->query['actionsColumn'];
}
// Add a set of non-overridable defaults and save it as the column model
$colModel['name'] = 'actions';
$colModel['search'] = false;
$colModel['sortable'] = false;
$colModel['align'] = 'center';
}
jquery::addPlugin('betagrid');
$jqueryGrid = jquery::addQuery('#' . $attributes['table']['id'])->jqGrid($this->jquery);
//.........这里部分代码省略.........
示例6: foreach
if ($grid->get('display_foot')) {
echo GRID_TAB . '<tfoot' . form::attributes($grid->foot_attributes) . '>' . PHP_EOL;
echo GRID_TAB . GRID_TAB . '<tr>' . PHP_EOL;
foreach ($grid->fields as $field) {
echo GRID_TAB . GRID_TAB . GRID_TAB . '<td>' . $field->foot . '</td>' . PHP_EOL;
}
echo GRID_TAB . GRID_TAB . '</tr>' . PHP_EOL;
if ($grid->get('extra_row_foot')) {
echo GRID_TAB . GRID_TAB . '<tr>' . PHP_EOL;
echo GRID_TAB . GRID_TAB . GRID_TAB . $grid->extra_row_foot . PHP_EOL;
echo GRID_TAB . GRID_TAB . '</tr>' . PHP_EOL;
}
echo GRID_TAB . '</tfoot>' . PHP_EOL;
}
if ($grid->get('display_body')) {
echo GRID_TAB . '<tbody' . form::attributes($grid->body_attributes) . '>' . PHP_EOL;
}
$i = 0;
// Now go for the rows
foreach ($grid->data as $data_row) {
if ($i % 2 == 1) {
$class = $grid->css_class_row_B;
} else {
$class = $grid->css_class_row_A;
}
$i++;
echo GRID_TAB . GRID_TAB . '<tr class="' . $class . '">' . PHP_EOL;
foreach ($grid->fields as $field) {
if ($field instanceof Actionfield_Core) {
$field->set('value', $data_row);
} else {
示例7:
<?php
echo form::textarea($field->name, $field->value, form::attributes($field->extra), $field->encode);
示例8: input
/**
* Creates an HTML form input tag. Defaults to a text type.
* The default behavior is replicated here because we need to disable specialchars which
* would only apply if we were not using doctrine
*
* @param string|array input name or an array of HTML attributes
* @param string input value, when using a name
* @param string a string to be attached to the end of the attributes
* @param boolean encode existing entities
* @return string
*/
public static function input($data, $value = NULL, $extra = '', $double_encode = TRUE)
{
if (empty($data['type']) || $data['type'] != 'hidden') {
// Add the Bluebox defaults (such as css classes)
list($data, $value, $extra) = self::_addDefaults(__FUNCTION__, $data, $value, $extra);
}
// Type and value are required attributes
$data += array('type' => 'text', 'value' => $value);
return '<input' . form::attributes($data) . ' ' . $extra . ' />';
}
示例9: label
/**
* Creates an HTML form label tag.
*
* @param string|array label "for" name or an array of HTML attributes
* @param string label text or HTML
* @param string a string to be attached to the end of the attributes
* @return string
*/
public static function label($data = '', $text = '', $extra = '')
{
if (!is_array($data)) {
if (strpos($data, '[') !== NO) {
$data = preg_replace('/\\[.*\\]/', '', $data);
}
$data = empty($data) ? array() : array('for' => $data);
}
return '<label' . form::attributes($data) . ' ' . $extra . '>' . $text . '</label>';
}
示例10: foreach
<?php
// For every action that we got
foreach ($field->action as $action => $value_field) {
// Create <a href="URL/action/ID">TEXT</a>
$link = '/' . $action . '/' . $field->value->{$value_field};
echo html::anchor($field->url[$action] . $link, $field->text[$action], form::attributes($field->extra), $field->protocol) . ' ';
}
示例11: elseif
<?php
$checked = false;
// Is this field to be checked?
if (is_array($field->checked)) {
if (in_array($field->value, $field->checked)) {
$checked = true;
}
} elseif ($field->value == $field->checked) {
$checked = true;
}
echo form::checkbox($field->name . '[]', $field->value, $checked, form::attributes($field->extra));
示例12:
<?php
echo form::password($field->name, $field->value, form::attributes($field->extra));
示例13:
<?php
$selected = false;
if ($field->value == $field->selected) {
$selected = true;
}
echo form::radio($field->name, $field->value, $selected, form::attributes($field->extra));
示例14:
<?php
echo form::dropdown($field->name, $field->options, $field->value, form::attributes($field->extra));
示例15:
<?php
echo form::input($field->name, $field->value, form::attributes($field->extra), $field->encode);