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


PHP FormBuilder::macro方法代码示例

本文整理汇总了PHP中Illuminate\Html\FormBuilder::macro方法的典型用法代码示例。如果您正苦于以下问题:PHP FormBuilder::macro方法的具体用法?PHP FormBuilder::macro怎么用?PHP FormBuilder::macro使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Html\FormBuilder的用法示例。


在下文中一共展示了FormBuilder::macro方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: macro

 /**
  * Register a custom macro.
  *
  * @param string $name
  * @param callable $macro
  * @return void 
  * @static 
  */
 public static function macro($name, $macro)
 {
     \Illuminate\Html\FormBuilder::macro($name, $macro);
 }
开发者ID:nmkr,项目名称:basic-starter,代码行数:12,代码来源:_ide_helper.php

示例2: function

 * Create a select box field.
 *
 * @param  string  $name
 * @param  array   $list
 * @param  string  $selected
 * @param  array   $options
 * @return string
 */
FormBuilder::macro('selectMy', function ($name, $list = array(), $selected = null, $option = '', $options = array()) {
    // When building a select box the "value" attribute is really the selected one
    // so we will use that when checking the model or session for a value which
    // should provide a convenient method of re-populating the forms on post.
    $selected = $this->getValueAttribute($name, $selected);
    $options['id'] = $this->getIdAttribute($name, $options);
    if (!isset($options['name'])) {
        $options['name'] = $name;
    }
    // We will simply loop through the options and build an HTML value for each of
    // them until we have an array of HTML declarations. Then we will join them
    // all together into one single HTML element that can be put on the form.
    $html = array();
    foreach ($list as $value => $display) {
        $html[] = $this->getSelectOption($display, $value, $selected);
    }
    // Once we have all of this HTML, we can join this into a single element after
    // formatting the attributes into an HTML "attributes" string, then we will
    // build out a final select statement, which will contain all the values.
    $options = $this->html->attributes($options);
    $list = implode('', $html);
    return "<select{$options}>{$option}{$list}</select>";
});
开发者ID:Vatia13,项目名称:gbtimes,代码行数:31,代码来源:macros.php


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