本文整理汇总了PHP中Form::select方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::select方法的具体用法?PHP Form::select怎么用?PHP Form::select使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Form
的用法示例。
在下文中一共展示了Form::select方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: smarty_function_form_select
/**
* @param array $params
* @param Smarty_Internal_Template $smarty
*
* @throws SmartyException
* @return string
*
* @author Kovács Vince
*/
function smarty_function_form_select($params, Smarty_Internal_Template &$smarty)
{
if (!isset($params['_name'])) {
throw new SmartyException('Missing _name attribute for form_select tag');
}
$name = $params['_name'];
$list = isset($params['_list']) ? $params['_list'] : array();
if (isset($params['_default'])) {
$list = array('' => $params['_default']) + $list;
}
$selected = isset($params['_selected']) ? $params['_selected'] : (isset($params['_populate']) && $params['_populate'] ? \Input::get($name) : null);
$range = isset($params['_range']) && $params['_range'];
unset($params['_name']);
unset($params['_list']);
unset($params['_selected']);
unset($params['_range']);
unset($params['_populate']);
if ($range) {
if (!isset($params['_begin'])) {
throw new SmartyException('Missing _begin attribute for form_select tag');
}
if (!isset($params['_end'])) {
throw new SmartyException('Missing _end attribute for form_select tag');
}
$begin = $params['_begin'];
$end = $params['_end'];
unset($params['_begin']);
unset($params['_end']);
return Form::selectRange($name, $begin, $end, $selected, $params);
}
return Form::select($name, $list, $selected, $params);
}
示例2: buildActive
function buildActive()
{
$html = '';
$html .= '<label for="active">' . trans('admin.active') . '</label>';
$html .= Form::select('active', selectBoolean(), null, ['class' => 'form-control select2-simple', 'style' => 'width: 100%;']);
return $html;
}
示例3: displayForm
/** @inheritdoc */
public static function displayForm($value, &$settings, $model)
{
// No point in ever showing this field if lang isn't enabled
if (!\CMF::$lang_enabled) {
return '';
}
\Lang::load('languages', true, 'en', true, true);
$settings = static::settings($settings);
$include_label = isset($settings['label']) ? $settings['label'] : true;
$required = isset($settings['required']) ? $settings['required'] : false;
$errors = $model->getErrorsForField($settings['mapping']['fieldName']);
$has_errors = count($errors) > 0;
$input_attributes = isset($settings['input_attributes']) ? $settings['input_attributes'] : array('class' => 'input-xxlarge');
if ($settings['active_only']) {
$options = array_map(function ($lang) {
return \Arr::get(\Lang::$lines, 'en.languages.' . $lang['code'], \Lang::get('admin.errors.language.name_not_found'));
}, \CMF\Model\Language::select('item.code', 'item', 'item.code')->orderBy('item.pos', 'ASC')->where('item.visible = true')->getQuery()->getArrayResult());
} else {
$options = \Arr::get(\Lang::$lines, 'en.languages', array());
}
// Whether to allow an empty option
if (isset($settings['mapping']['nullable']) && $settings['mapping']['nullable'] && !$required && $settings['allow_empty']) {
$options = array('' => '') + $options;
}
$label = !$include_label ? '' : \Form::label($settings['title'] . ($required ? ' *' : '') . ($has_errors ? ' - ' . $errors[0] : ''), $settings['mapping']['fieldName'], array('class' => 'item-label'));
$input = \Form::select($settings['mapping']['fieldName'], $value, $options, $input_attributes);
if (isset($settings['wrap']) && $settings['wrap'] === false) {
return $label . $input;
}
return html_tag('div', array('class' => 'controls control-group' . ($has_errors ? ' error' : '')), $label . $input);
}
示例4: select
public static function select($name, $label, $attribs = array(), $modelPair = NULL, $wrapper = 1)
{
if (isset($attribs['valueArray'])) {
$selectValueArray = $attribs['valueArray'];
unset($attribs['valueArray']);
}
if (isset($attribs['range'])) {
for ($i = $attribs['range'][0]; $i <= $attribs['range'][1]; $i++) {
$selectValueArray[$i] = $i;
}
unset($attribs['range']);
}
$value = isset($attribs['value']) ? (string) $attribs['value'] : null;
if (is_array($modelPair)) {
$modelName = $modelPair[0];
$selectValueColumn = $modelPair[1];
$selectNameColumn = $modelPair[2];
$model = $modelName::orderBy($selectNameColumn)->get();
foreach ($model as $item) {
$selectValueArray[$item->{$selectValueColumn}] = $item->{$selectNameColumn};
}
}
$selectOutput = Form::select($name, $selectValueArray, $value, $attribs) . self::_getInputError($name);
if ($wrapper == 1) {
return '<li id="' . $name . '_label">' . Form::label($name, $label) . '<div id="' . $name . '_input" class="input_field">' . $selectOutput . '</div></li>';
} else {
return $selectOutput;
}
}
示例5: select
protected function select($data, $show)
{
$select = [];
foreach ($data as $d) {
if (is_array($show)) {
$value = '';
foreach ($show as $show_key) {
$value .= Str::title($show_key) . ': ' . $d[$show_key];
if (end($show) != $show_key) {
$value .= ' | ';
}
}
} elseif (is_callable($show)) {
$value = $show($d);
} else {
$value = $d[$show];
}
$select[$d['id']] = $value;
}
if (Request::has($this->name)) {
$this->id = Request::get($this->name);
} else {
if (isset($this->value->id)) {
$this->id = $this->value->id;
} else {
$this->id = $this->value;
}
}
echo \Form::select($this->name, ['0' => Request::ajax() ? '(current)' : '(none)'] + $select, $this->id, $this->attributes);
}
示例6: build
public function build()
{
$output = "";
if (!isset($this->style)) {
$this->style = "margin:0 2px 0 0; vertical-align: middle";
}
unset($this->attributes['id']);
if (parent::build() === false) {
return;
}
switch ($this->status) {
case "disabled":
case "show":
if (!isset($this->value)) {
$output = $this->layout['null_label'];
} else {
$output = $this->description;
}
$output = "<div class='help-block'>" . $output . " </div>";
break;
case "create":
case "modify":
$this->attributes['multiple'] = 'multiple';
$output .= \Form::select($this->name . '[]', $this->options, $this->values, $this->attributes);
$output .= $this->extra_output;
break;
case "hidden":
$output = Form::hidden($this->name, $this->value);
break;
default:
}
$this->output = $output;
}
示例7: build
function build()
{
$output = "";
if (!isset($this->style) and !isset($this->attributes['style'])) {
$this->style = "width:290px;";
}
unset($this->attributes['type'], $this->attributes['size']);
if (parent::build() === false) {
return;
}
switch ($this->status) {
case "disabled":
case "show":
if (!isset($this->value)) {
$output = $this->layout['null_label'];
} else {
$output = $this->description;
}
$output = "<div class='help-block'>" . $output . "</div>";
break;
case "create":
case "modify":
$output = \Form::select($this->name, $this->options, $this->value, $this->attributes) . $this->extra_output;
break;
case "hidden":
$output = Form::hidden($this->name, $this->value);
break;
default:
}
$this->output = $output;
}
示例8: recurse_pages
function recurse_pages($pages, $spaces = 0, $layoutsBlocks = [], $pageWidgets = [], $pagesWidgets = [])
{
$data = '';
foreach ($pages as $page) {
// Блок
$currentBlock = array_get($pageWidgets, $page['id'] . '.0');
$currentPosition = array_get($pageWidgets, $page['id'] . '.1');
$data .= '<tr data-id="' . $page['id'] . '" data-parent-id="' . $page['parent_id'] . '">';
$data .= '<td>';
if (!empty($page['childs'])) {
$data .= '<div class="input-group">';
}
$data .= Form::select('blocks[' . $page['id'] . '][block]', [], $currentBlock, ['class' => 'widget-blocks form-control', 'data-layout' => $page['layout_file'], 'data-value' => $currentBlock]);
if (!empty($page['childs'])) {
$data .= "<div class=\"input-group-btn\">" . Form::button(NULL, ['data-icon' => 'level-down', 'class' => 'set_to_inner_pages btn btn-warning', 'title' => trans('widgets::core.button.select_childs')]) . '</div></div>';
}
$data .= '</td><td>';
$data .= Form::text('blocks[' . $page['id'] . '][position]', (int) $currentPosition, ['maxlength' => 4, 'size' => 4, 'class' => 'form-control text-right widget-position']);
$data .= '</td><td></td>';
if (acl_check('page::edit')) {
$data .= '<th>' . str_repeat("- ", $spaces) . link_to_route('backend.page.edit', $page['title'], [$page['id']]) . '</th>';
} else {
$data .= '<th>' . str_repeat("- ", $spaces) . $page['title'] . '</th>';
}
$data .= '</tr>';
if (!empty($page['childs'])) {
$data .= recurse_pages($page['childs'], $spaces + 5, $layoutsBlocks, $pageWidgets, $pagesWidgets);
}
}
return $data;
}
示例9: blockZones
/**
* [blockZones description]
* @param [type] $page_id [description]
* @param [type] $block_id [description]
* @param [type] $zone [description]
* @param string $name [description]
* @param string $id [description]
* @return [type] [description]
*/
public function blockZones($page_id, $block_id, $zone, $name = 'change-zone', $id = 'change-zone')
{
if ($block_id) {
$layout = $this->page->find($page_id)->layout;
$zones = \Theme::zones($layout);
return \Form::select($name, $zones, $zone, array('id' => $id, 'data-page' => $page_id, 'class' => 'form-control'));
}
}
示例10: input
public function input($name, array $attr = NULL)
{
if (is_array($this->choices)) {
return Form::select($name, $this->choices, $this->value, $attr);
} else {
return Form::input($name, $this->verbose(), $attr);
}
}
示例11: formComponent
/**
* Form Component
*/
public static function formComponent()
{
$_templates = Themes::getTemplates();
foreach ($_templates as $template) {
$templates[basename($template, '.template.php')] = basename($template, '.template.php');
}
echo '<div class="col-xs-3">' . Form::open() . Form::hidden('csrf', Security::token()) . Form::label('sandbox_form_template', __('Sandbox template', 'sandbox')) . Form::select('sandbox_form_template', $templates, Option::get('sandbox_template'), array('class' => 'form-control')) . Html::br() . Form::submit('sandbox_component_save', __('Save', 'sandbox'), array('class' => 'btn btn-default')) . Form::close() . '</div>';
}
示例12: input
public function input($name, $value, array $attr = NULL)
{
$model = Sprig::factory($this->model);
$choices = $model->select_list($model->pk());
if ($this->empty) {
Arr::unshift($choices, '', '-- ' . __('None'));
}
return Form::select($name, $choices, $this->verbose($value), $attr);
}
示例13: option
public function option($data, $name, $options, $default = NULL, $attrs = array())
{
if (!$this->view->preview) {
return;
}
$default_attrs = array('style' => 'display:none', 'property' => $name, 'property-type' => 'option');
$attrs = Arr::merge($default_attrs, $attrs);
return Form::select($name, $options, $this->get($data, $name, $default), $attrs);
}
示例14: selectGroup
function selectGroup($name, $options, $value = NULL, $errors, $attributes = [])
{
$errorClass = $errors->first($name) ? "has-error" : "";
$output = "<div class='form-group {$errorClass}'>";
$output .= Form::label($name, ucwords($name));
$output .= Form::select($name . "[]", $options, $value, $attributes);
$output .= $errors->first($name, '<label>:message</label>');
return "{$output}</div>";
}
示例15: addTargetLanguageSelect
/**
* @param $targetLanguage
* @return string
*
*/
function addTargetLanguageSelect($targetLanguage)
{
$selectedValue = isset($targetLanguage->value) && isset($targetLanguage->value->text) && ($targetLanguage->value->text == 'fr' || $targetLanguage->value->text == 'en') ? $targetLanguage->value->text : 'fr';
$p = "<p>";
$p .= "<label>" . $targetLanguage->label . "</label>";
$p .= Form::select('extend[' . $targetLanguage->key . ']', array('fr' => 'Français', 'en' => 'Anglais'), $selectedValue, array('class' => ''));
$p .= "</p>";
return $p;
}