本文整理汇总了PHP中FormHelper::hidden方法的典型用法代码示例。如果您正苦于以下问题:PHP FormHelper::hidden方法的具体用法?PHP FormHelper::hidden怎么用?PHP FormHelper::hidden使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FormHelper
的用法示例。
在下文中一共展示了FormHelper::hidden方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: file
/**
* ファイルインプットボックス出力
* 画像の場合は画像タグ、その他の場合はファイルへのリンク
* そして削除用のチェックボックスを表示する
* [カスタムオプション]
* imgsize・・・画像のサイズを指定する
*
* @param string $fieldName
* @param array $options
* @return string
* @access public
*/
function file($fieldName, $options = array())
{
$linkOptions = $_options = array('imgsize' => 'midium', 'rel' => '', 'title' => '');
$options = $this->_initInputField($fieldName, Set::merge($_options, $options));
$linkOptions['imgsize'] = $options['imgsize'];
$linkOptions['rel'] = $options['rel'];
$linkOptions['title'] = $options['title'];
unset($options['imgsize']);
unset($options['rel']);
unset($options['title']);
$view =& ClassRegistry::getObject('view');
$_field = $view->entity();
$modelName = $_field[0];
$field = $_field[1];
if (ClassRegistry::isKeySet($modelName)) {
$model =& ClassRegistry::getObject($modelName);
} else {
return;
}
$fileLinkTag = $this->fileLink($fieldName, $linkOptions);
$fileTag = parent::file($fieldName, $options);
$delCheckTag = parent::checkbox($modelName . '.' . $field . '_delete') . parent::label($modelName . '.' . $field . '_delete', '削除する');
$hiddenValue = $this->value($fieldName . '_');
$fileValue = $this->value($fieldName);
if (is_array($fileValue) && empty($fileValue['tmp_name']) && $hiddenValue) {
$hiddenTag = parent::hidden($modelName . '.' . $field . '_', array('value' => $hiddenValue));
} else {
$hiddenTag = parent::hidden($modelName . '.' . $field . '_', array('value' => $this->value($fieldName)));
}
$out = $fileTag;
if ($fileLinkTag) {
$out .= ' ' . $delCheckTag . $hiddenTag . '<br />' . $fileLinkTag;
}
return '<div class="upload-file">' . $out . '</div>';
}
示例2: fileInput
/**
* overide form->input.
*
* @param string $fieldName This should be "Modelname.fieldname"
* @param array $options Each type of input takes different options.
*/
public function fileInput($field, $options = array())
{
// get model and field
$explodeField = explode('.', $field);
if (!is_array($explodeField)) {
return;
}
$modelName = $explodeField[0];
$fieldName = $explodeField[1];
if (!empty($options['upload-flag'])) {
$inputFile = parent::file($field, $options);
$fileUploaed = parent::hidden($field . '_uploaded', array('value' => empty($this->request->data[$modelName][$fieldName]) ? '' : $this->request->data[$modelName][$fieldName]));
$stepValidate = parent::hidden($modelName . '.upload_flag');
return $inputFile . $fileUploaed . $stepValidate;
} else {
// input in step form confirm
$inputFile = parent::hidden($field, array('value' => empty($this->request->data[$modelName][$fieldName]) ? '' : $this->request->data[$modelName][$fieldName]));
$fileUploaed = parent::hidden($field . '_uploaded', array('value' => empty($this->request->data[$modelName][$fieldName]) ? '' : $this->request->data[$modelName][$fieldName]));
return $inputFile . $fileUploaed;
}
}
示例3: input
/**
* Extend the default input function by allowing for use of a hidden
* field instead of a select, if there's only one option.
* Also, add popup help link, if available.
*/
function input($fieldName, $options = array())
{
$this->setEntity($fieldName);
$model = Inflector::tableize($this->model());
$shortFieldName = $this->field();
// Check for HTML5 field types, and revert them to text.
// TODO: CakePHP 2 should handle this natively; remove return value mangling too.
$html5types = array('number', 'email', 'tel', 'url');
if (array_key_exists('type', $options) && in_array($options['type'], $html5types)) {
$html5type = $options['type'];
$options['type'] = 'text';
}
// If no options were provided, check if there's some configured
if (!array_key_exists('type', $options) && !array_key_exists('options', $options) && Configure::read("options.{$model}.{$shortFieldName}") !== null) {
$options['options'] = Configure::read("options.{$model}.{$shortFieldName}");
}
if (is_array($options) && array_key_exists('hide_single', $options) && $options['hide_single']) {
unset($options['hide_single']);
$is_select = array_key_exists('type', $options) && $options['type'] == 'select' || !array_key_exists('type', $options);
if ($is_select) {
if (!isset($options['options'])) {
$view =& ClassRegistry::getObject('view');
$varName = Inflector::variable(Inflector::pluralize(preg_replace('/_id$/', '', $this->field())));
$varOptions = $view->getVar($varName);
if (is_array($varOptions)) {
$options['options'] = $varOptions;
}
}
if (array_key_exists('options', $options) && count($options['options']) == 1) {
$value = reset(array_keys($options['options']));
if (!is_array($options['options'][$value])) {
return parent::hidden($fieldName, array('value' => $value, 'secure' => false));
}
}
}
}
// Check if we need to allow a larger date range
if (!empty($options['looseYears']) && !empty($options['minYear'])) {
$value = $this->value($fieldName);
if (!empty($value)) {
if (is_array($value)) {
$year = $value['year'];
} else {
$year = date('Y', strtotime($value));
}
// Account for null values in the database; we don't really want to give all options back to Roman times...
if ($year > 0) {
$options['minYear'] = min($options['minYear'], $year - 1);
$options['maxYear'] = max($options['maxYear'], $year + 1);
}
}
}
// Check if there's online help for this field
$help_file = VIEWS . 'elements' . DS . 'help' . DS . $model . DS . 'edit' . DS . low($shortFieldName) . '.ctp';
if (file_exists($help_file)) {
$help = ' ' . $this->ZuluruHtml->help(array('action' => $model, 'edit', low($shortFieldName)));
// For text boxes or multiple selects, the help icon should go at the end of the label
if (array_key_exists('cols', $options) || array_key_exists('type', $options) && $options['type'] == 'textarea' || array_key_exists('multiple', $options) && ($options['multiple'] == 'checkbox' || $options['multiple'] === true)) {
// If we don't have a label specified, figure it out.
if (array_key_exists('label', $options)) {
if ($options['label'] === false) {
$options['label'] = $help;
} else {
$options['label'] = $options['label'] . ' ' . $help;
}
} else {
// This code copied from FormHelper->label
if (strpos($fieldName, '.') !== false) {
$text = array_pop(explode('.', $fieldName));
} else {
$text = $fieldName;
}
if (substr($text, -3) == '_id') {
$text = substr($text, 0, strlen($text) - 3);
}
$text = __(Inflector::humanize(Inflector::underscore($text)), true);
$options['label'] = $text . ' ' . $help;
}
} else {
if (array_key_exists('multiple', $options) && $options['multiple'] == 'checkbox') {
$location = 'between';
} else {
$location = 'after';
}
if (array_key_exists($location, $options)) {
$options[$location] = $help . $options[$location];
} else {
$options[$location] = $help;
}
}
}
$ret = parent::input($fieldName, $options);
if (isset($html5type)) {
$ret = str_replace('type="text"', "type=\"{$html5type}\"", $ret);
}
//.........这里部分代码省略.........
示例4: array
<? $this->set('ID', "library-page") ?>
<? $this->set('TITLE', "Liste des images") ?>
<div id="content" style="width:800px">
<div id="main">
<? $i = 0 ?>
<form action="#">
<fieldset>
<legend>Informations sur l'image</legend>
<?php
echo FormHelper::hidden('path', $Picture);
?>
<div class="<?php
echo ++$i % 2 ? 'odd' : 'even';
?>
">
<label for="name">Titre de l'image</label>
<?php
echo FormHelper::text('name', $Picture, array('size' => 100));
?>
</div>
<div class="<?php
echo ++$i % 2 ? 'odd' : 'even';
?>
">
<label for="width">Taille</label>
示例5: testHidden
public function testHidden()
{
$this->assertEqual(FormHelper::hidden('name', 'value', array('class' => 'myClass')), '<input type="hidden" name="name" class="myClass" value="value" id="name">');
$this->assertEqual(FormHelper::hidden('name', $this->Model, array('class' => 'myClass')), '<input type="hidden" name="name" class="myClass" value="obj" id="name">');
}
示例6: datetime
static function datetime($name, $value = '', $years = array(), $attributes = array())
{
$prefix = '_' . $name . '_';
$value = is_object($value) ? $value[$name] : $value;
$date = $time = null;
$year = $month = $day = null;
$hour = $minutes = $seconds = null;
$with_seconds = null;
if (!$value || $value == 'NOW()' || $value == 'TODAY()') {
$value = date('Y-m-d H:i:s');
}
if (isset($attributes['seconds']) && $attributes['seconds'] == true) {
$with_seconds = true;
unset($attributes['seconds']);
}
if (@(list($date, $time) = explode(' ', $value))) {
@(list($year, $month, $day) = explode('-', $date));
@(list($hour, $minutes, $seconds) = explode(':', $time));
}
$html = self::date($name, $value, (array) $years, (array) $attributes);
$html .= ' ' . __('à') . ' ';
$html .= FormHelper::text($prefix . 'hour', $hour, array('size' => 2, 'maxlength' => 2));
$html .= ' : ';
$html .= FormHelper::text($prefix . 'minutes', $minutes, array('size' => 2, 'maxlength' => 2));
if ($with_seconds) {
$html .= ' : ';
$html .= FormHelper::text($prefix . 'seconds', $seconds, array('size' => 2, 'maxlength' => 2));
} else {
$html .= FormHelper::hidden($prefix . 'seconds', $seconds);
}
return $html;
}