当前位置: 首页>>代码示例>>PHP>>正文


PHP FormHelper类代码示例

本文整理汇总了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;
 }
开发者ID:ruxon,项目名称:module-ruxon,代码行数:60,代码来源:RuxonFormViewMultiselectColumn.class.php

示例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()));
     }
 }
开发者ID:ruxon,项目名称:module-ruxon,代码行数:31,代码来源:RuxonFormViewListColumn.class.php

示例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));
 }
开发者ID:RBSWebFactory,项目名称:modules.form,代码行数:34,代码来源:BlockFormInputView.class.php

示例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()));
 }
开发者ID:ruxon,项目名称:module-ruxon,代码行数:25,代码来源:RuxonFormViewListTreeColumn.class.php

示例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;
 }
开发者ID:h3rb,项目名称:page,代码行数:34,代码来源:AJAX.php

示例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;
 }
开发者ID:fozeek,项目名称:application,代码行数:7,代码来源:imageobject.class.php

示例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;
 }
开发者ID:heimrichhannot,项目名称:contao-formhybrid,代码行数:45,代码来源:Validator.php

示例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';
     }
 }
开发者ID:heimrichhannot,项目名称:contao-formhybrid,代码行数:32,代码来源:FrontendWidget.php

示例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);
 }
开发者ID:busytoby,项目名称:gitrbug,代码行数:59,代码来源:origami_form.php

示例10: postLink

 public function postLink($title, $url = null, $options = array(), $confirmMessage = false)
 {
     if ($this->_aclCheck($url)) {
         return parent::postLink($title, $url, $options, $confirmMessage);
     }
     return '';
 }
开发者ID:ishapkin,项目名称:CakePHP-Acl-Link-Helper,代码行数:7,代码来源:AclLinkHelper.php

示例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);
 }
开发者ID:laiello,项目名称:plankonindia,代码行数:7,代码来源:CroogoFormHelper.php

示例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');
 }
开发者ID:Onasusweb,项目名称:DataTypes,代码行数:13,代码来源:DataTypeFormHelper.php

示例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 .= '&nbsp;' . $delCheckTag . $hiddenTag . '<br />' . $fileLinkTag;
     }
     return '<div class="upload-file">' . $out . '</div>';
 }
开发者ID:nojimage,项目名称:basercms,代码行数:47,代码来源:upload.php

示例14: end

 function end($options = null)
 {
     if ($this->_fieldsetOpen === true) {
         return "</fieldset>\n" . parent::end($options);
     }
     return parent::end($options);
 }
开发者ID:kouak,项目名称:ircube,代码行数:7,代码来源:uni_form.php

示例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;
 }
开发者ID:09jz0138,项目名称:skit,代码行数:25,代码来源:exform.php


注:本文中的FormHelper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。