本文整理汇总了PHP中FormHelper类的典型用法代码示例。如果您正苦于以下问题:PHP FormHelper类的具体用法?PHP FormHelper怎么用?PHP FormHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FormHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
public function render()
{
$value = 0;
$value_id = 0;
$oDataProvider = new DataProvider($this->getDataSource());
$oData = $oDataProvider->execute();
//echo '<pre>', print_r($oData, true), '</pre>'; die();
$aResult = array();
/*$aResult[] = array(
'Name' => $this->getDefaultText(),
'Value' => $this->getDefaultValue()
); */
if ($this->getDefault()) {
$aRs = array();
if (preg_match("#:(.*?)#isU", $this->getDefault(), $aRs)) {
$value = Toolkit::getInstance()->request->get($aRs[1], Request::C_GET);
}
}
//echo 'val:', print_r($this->getValue()->toSimpleArray(), true);
if ($this->getValue()) {
$value_id = $this->getValue()->toSimpleArray();
}
if ($oData->count() > 0) {
foreach ($oData as $itm) {
$getter = 'get' . $this->getValueField();
$aResultTmp = array('Value' => call_user_func(array($itm, $getter)), 'Name' => $this->getTextFormat());
$aRs = array();
if (preg_match_all("/:(.*):/iU", $aResultTmp['Name'], $aRs)) {
foreach ($aRs[1] as $k => $val) {
$value = $itm;
if (strpos($val, "-") !== false) {
$xVal = explode("-", $val);
foreach ($xVal as $_val) {
$sGetter = 'get' . $_val;
$value = call_user_func(array($value, $sGetter));
}
} else {
$sGetter = 'get' . $val;
$value = call_user_func(array($value, $sGetter));
}
$aResultTmp['Name'] = str_replace($aRs[0][$k], $value, $aResultTmp['Name']);
}
}
/*if (isset($aContainer['IsTree']) && $aContainer['IsTree'] == true) {
$aResultTmp['Name'] = str_repeat(' |-- ', $itm->getTreeLevel() - 1).$aResultTmp['Name'];
}*/
$aResult[] = $aResultTmp;
}
}
$sResult = FormHelper::multiselect($this->getAlias() . '[]', $value_id, $aResult, array('class' => 'multiselect', 'id' => 'field_' . $this->getAlias()));
if ($this->getExtended()) {
$sResult .= '<script>$(document).ready(
function()
{
$(\'#field_' . $this->getAlias() . '\').multiselect({sortable: false, searchable: false});
}
);</script>';
}
echo $sResult;
}
示例2: render
public function render()
{
$value = 0;
$value_id = 0;
$aDataSource = $this->getDataSource();
if ($this->getIsTree()) {
$aDataSource[2]['Criteria']['ParentId'] = 0;
}
$oDataProvider = new DataProvider($aDataSource);
$oData = $oDataProvider->execute();
//echo '<pre>', print_r($oData, true), '</pre>'; die();
$aResult = array();
$aResult[] = array('Name' => $this->getDefaultText(), 'Value' => $this->getDefaultValue());
if ($this->getDefault()) {
$aRs = array();
if (preg_match("#:(.*?)#isU", $this->getDefault(), $aRs)) {
$value = Toolkit::getInstance()->request->get($aRs[1], Request::C_GET);
}
}
if ($this->getValue()) {
$value_id = $this->getValue();
}
$aResult = $this->createRow($oData, $aResult);
if ($this->getOnChange()) {
$tmpChange = $this->getOnChange();
echo FormHelper::selectbox($this->getAlias(), $value_id, $aResult, array('class' => 'selectbox ajax_response_list', 'data-field' => $tmpChange[0], 'data-id' => $this->getValue(), 'id' => 'field_' . $this->getAlias()));
//$.post('/structure/page_backend/typeParams', {Id: $this->getValue()}, function (data) { /* response */ });
} else {
echo FormHelper::selectbox($this->getAlias(), $value_id, $aResult, array('class' => 'selectbox', 'id' => 'field_' . $this->getAlias()));
}
}
示例3: execute
/**
* Mandatory execute method...
*
* @param block_BlockContext $context
* @param block_BlockRequest $request
*/
public function execute($context, $request)
{
FormHelper::addScriptsAndStyles($context);
$form = $this->getParameter('form');
$this->setTemplateName('markup/' . $form->getMarkup() . '/Form');
$this->setAttribute('form', $form);
$contents = array();
form_FormService::getInstance()->buildContentsFromRequest($form->getDocumentNode()->getChildren(), $contents, $request, $form);
$this->setAttribute('elements', $contents);
if ($this->hasParameter('errors')) {
$this->setAttribute('errors', $this->getParameter('errors'));
}
$this->setAttribute('selfUrl', $_SERVER['REQUEST_URI']);
if ($request->getParameter(form_FormConstants::BACK_URL_PARAMETER)) {
$backUrl = $request->getParameter(form_FormConstants::BACK_URL_PARAMETER);
} else {
if (isset($_SERVER['HTTP_REFERER'])) {
$backUrl = $_SERVER['HTTP_REFERER'];
} else {
$backUrl = website_WebsiteModuleService::getInstance()->getCurrentWebsite()->getUrl();
}
}
$this->setAttribute("receiverLabels", $this->getParameter("receiverLabels"));
$this->setAttribute('requestParameters', $request->getParameters());
$this->setAttribute('backUrl', $backUrl);
$this->setAttribute('useCaptcha', $form->getDocumentService()->hasToUseCaptcha($form));
$this->setAttribute('jQueryConditionalElement', $form->getDocumentService()->getJQueryForConditionalElementsOf($form));
}
示例4: render
public function render()
{
$value = 0;
$value_id = 0;
$aDataSource = $this->getDataSource();
$aDataSource[2]['Criteria']['ParentId'] = 0;
$oDataProvider = new DataProvider($aDataSource);
$oData = $oDataProvider->execute();
//echo '<pre>', print_r($oData, true), '</pre>'; die();
$aResult = array();
$aResult[] = array('Name' => $this->getDefaultText(), 'Value' => $this->getDefaultValue());
if ($this->getDefault()) {
$aRs = array();
if (preg_match("#:(.*?)#isU", $this->getDefault(), $aRs)) {
$value = Toolkit::getInstance()->request->get($aRs[1], Request::C_GET);
}
}
if ($this->getValue()) {
$value_id = $this->getValue();
}
if ($oData->count() > 0) {
$aResult = $this->getChilds($oData, 1, $aResult);
}
echo FormHelper::selectbox($this->getAlias(), $value_id, $aResult, array('class' => 'selectbox', 'id' => 'field_' . $this->getAlias()));
}
示例5: FormPost
public function FormPost()
{
$out = array();
$out["map"] = array();
foreach (getpost() as $name => $value) {
if (matches($name, "map")) {
$map = json_decode(FormHelper::Decode($value));
foreach ($map as $mapped) {
$parts = explode('|', $mapped);
if (contains($parts[0], '__')) {
$d = explode('__', $parts[0]);
if (!isset($out["map"][$d[0]])) {
$out["map"][$d[0]] = array();
}
$out["map"][$d[0]][$d[1]] = AJAX::fp($parts[1]);
} else {
$mapped[$parts[0]] = AJAX::fp($parts[1]);
}
}
} else {
if (contains($name, '__')) {
$d = explode("__", $name);
if (!isset($out[$d[0]])) {
$out[$d[0]] = array();
}
$out[$d[0]][$d[1]] = base64_decode(urldecode($value));
} else {
$out[$name] = FormHelper::Decode($value);
}
}
}
$out['signal'] = json_decode($out['signal'], true);
return $out;
}
示例6: __printFormNew
public static function __printFormNew($shema)
{
$html = '<div style="border-radius: 2px;border: 1px solid #B9B9B9;"><div style="background: #F9F9F9;padding :4px;">';
$html .= FormHelper::getInstance()->file($shema["Field"], array("id" => $shema["Field"]));
$html .= '</div></div>';
return $html;
}
示例7: isValidOption
/**
* check if options are available and find current value in list
* if not found: do not set the value, otherwise potential sql injection vulnerability
* TODO: try to check against options_callbacks as well!!!
*
* @param $varValue
* @param $arrData
*
* @return bool
*/
public static function isValidOption($varValue, &$arrData, $objDc = null)
{
$arrOptions = FormHelper::getFieldOptions($arrData, $objDc);
if (empty($arrOptions)) {
$arrOptions = array(0, 1);
}
$blnIsAssociative = $arrData['eval']['isAssociative'] || array_is_assoc($arrOptions);
$intFounds = 0;
foreach ($arrOptions as $k => $v) {
if (!is_array($v)) {
$checkValue = $blnIsAssociative ? $k : $v;
if (is_array($varValue)) {
if (in_array(urldecode($checkValue), array_map('urldecode', $varValue))) {
$intFounds++;
}
} elseif (urldecode($checkValue) == urldecode($varValue)) {
$intFounds++;
break;
}
continue;
}
$blnIsAssoc = array_is_assoc($v);
foreach ($v as $kk => $vv) {
$checkValue = $blnIsAssoc ? $kk : $vv;
if (urldecode($checkValue) == urldecode($varValue)) {
$intFounds++;
break;
}
}
}
if (is_array($varValue) && $intFounds < count($varValue) || !is_array($varValue) && $intFounds < 1) {
return false;
}
return true;
}
示例8: validateGetAndPost
/**
* Validate the user input and set the value
*/
public static function validateGetAndPost($objWidget, $strMethod, $strFormId, $arrData)
{
if ($strMethod == FORMHYBRID_METHOD_GET) {
$varValue = $objWidget->validator(static::getGet($objWidget, $objWidget->strName));
$varValue = FormHelper::xssClean($varValue, $objWidget->allowHtml);
} else {
// \Widget->validate retrieves submission data form post -> xss related stuff needs to be removed beforehands
$_POST[$objWidget->name] = FormHelper::xssClean($_POST[$objWidget->name], $objWidget->allowHtml);
// Captcha needs no value, just simple validation
if ($objWidget instanceof \FormCaptcha) {
$varValue = '';
$objWidget->validate();
} else {
$objWidget->validate();
$varValue = $objWidget->value;
}
}
$objWidget->varValue = $varValue;
// HOOK: validate form field callback
if (isset($GLOBALS['TL_HOOKS']['formHybridValidateFormField']) && is_array($GLOBALS['TL_HOOKS']['formHybridValidateFormField'])) {
foreach ($GLOBALS['TL_HOOKS']['formHybridValidateFormField'] as $callback) {
$objClass = \Controller::importStatic($callback[0]);
$objClass->{$callback[1]}($objWidget, $strFormId, $arrData);
}
}
if ($objWidget->hasErrors()) {
$objWidget->class = 'error';
}
}
示例9: input
function input($fieldName, $options = array())
{
if (ClassRegistry::isKeySet($this->model())) {
$model =& ClassRegistry::getObject($this->model());
if ($model->isOrigamiColumn($fieldName)) {
$type = $model->getOrigamiColumnType($fieldName);
if (method_exists($this, $type)) {
unset($options['type']);
// We are specifying the type, so we need to remove any user specified types
$out = $this->{$type}($fieldName, $options);
// The code is this section is mostly copied from the cake php
// FormHelper input method
$div = true;
$divOptions = array();
if (array_key_exists('div', $options)) {
$div = $options['div'];
unset($options['div']);
}
if (!empty($div)) {
$divOptions['class'] = 'input';
$divOptions = $this->addClass($divOptions, $type);
if (is_string($div)) {
$divOptions['class'] = $div;
} elseif (is_array($div)) {
$divOptions = array_merge($divOptions, $div);
}
if (in_array($this->field(), $this->fieldset['validates'])) {
$divOptions = $this->addClass($divOptions, 'required');
}
if (!isset($divOptions['tag'])) {
$divOptions['tag'] = 'div';
}
}
if ($type != 'hidden') {
$error = null;
if (isset($options['error'])) {
$error = $options['error'];
unset($options['error']);
}
if ($error !== false) {
$errMsg = $this->error($fieldName, $error);
if ($errMsg) {
$out .= $errMsg;
$divOptions = $this->addClass($divOptions, 'error');
}
}
}
if (isset($divOptions) && isset($divOptions['tag'])) {
$tag = $divOptions['tag'];
unset($divOptions['tag']);
$out = $this->Html->tag($tag, $out, $divOptions);
}
// end cake php inputs copy
return $out;
}
}
}
return parent::input($fieldName, $options);
}
示例10: postLink
public function postLink($title, $url = null, $options = array(), $confirmMessage = false)
{
if ($this->_aclCheck($url)) {
return parent::postLink($title, $url, $options, $confirmMessage);
}
return '';
}
示例11: submit
public function submit($caption = null, $options = array())
{
$defaults = array('class' => 'btn', 'escape' => false);
$options = array_merge($defaults, $options);
list($caption, $options) = $this->_bootstrapGenerate($caption, $options);
return parent::submit($caption, $options);
}
示例12: __construct
/**
* Default Constructor
*
* @param View $View The View this helper is being attached to.
* @param array $settings Configuration settings for the helper.
*/
public function __construct(View $View, $settings = array())
{
parent::__construct($View, $settings);
//$this->DataType = ClassRegistry::init('DataTypes.DataType');
$this->DataTypeTemplate = ClassRegistry::init('DataTypes.DataTypeTemplate');
$this->DataTypeTemplatesPlugin = ClassRegistry::init('DataTypes.DataTypeTemplatesPlugin');
}
示例13: 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>';
}
示例14: end
function end($options = null)
{
if ($this->_fieldsetOpen === true) {
return "</fieldset>\n" . parent::end($options);
}
return parent::end($options);
}
示例15: dateYMD
function dateYMD($fieldName, $selected = null, $attributes = array(), $showEmpty = true)
{
if (!isset($this->options['month'])) {
$this->options['month'] = array();
for ($i = 1; $i <= 12; $i++) {
$this->options['month'][sprintf("%02d", $i)] = $i;
}
}
$sep = array('', '', '');
if (isset($attributes['separator'])) {
if (is_array($attributes['separator'])) {
$sep = $attributes['separator'];
$attributes['separator'] = "";
}
} else {
$attributes['separator'] = "";
$sep = array("年", "月", "日");
}
$ret = parent::dateTime($fieldName, 'YMD', 'NONE', $selected, $attributes, $showEmpty);
$ret = preg_replace('|</select>|', '{/select}' . @$sep[0], $ret, 1);
$ret = preg_replace('|</select>|', '{/select}' . @$sep[1], $ret, 1);
$ret = preg_replace('|</select>|', '{/select}' . @$sep[2], $ret, 1);
$ret = $ret = str_replace('{/select}', '</select>', $ret);
return $ret;
}