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


PHP _parse_form_attributes函数代码示例

本文整理汇总了PHP中_parse_form_attributes函数的典型用法代码示例。如果您正苦于以下问题:PHP _parse_form_attributes函数的具体用法?PHP _parse_form_attributes怎么用?PHP _parse_form_attributes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: fform_submit

 function fform_submit($data = '', $value = '', $extra = '')
 {
     $defaults = array('type' => 'submit', 'name' => !is_array($data) ? $data : '', 'value' => $value);
     if (!function_exists('_parse_form_attributes')) {
         return "The Foundation Form Helper requires the Form Helper, please load that first!";
     }
     return "<input " . _parse_form_attributes($data, $defaults) . $extra . " />";
 }
开发者ID:nyfagel,项目名称:codeigniter-extensions,代码行数:8,代码来源:foundationform_helper.php

示例2: input_requirement

/**
 * Form Element Requirement Indicator
 *
 * Creates the indicator that shows if a form element is required
 *
 * @param  string  the character or characters to show as the indication of requirement
 * @param  array   a key/value pair of attributes
 */
function input_requirement($indicator = '', $data = '')
{
    // ID isn't really a default. It's just here so it is applied before class, which is my preference.
    if (!empty($data['id'])) {
        $defaults['id'] = $data['id'];
    }
    $defaults['class'] = 'input-requirement';
    if (empty($indicator)) {
        $indicator = '&nbsp;';
    }
    return '<div ' . rtrim(_parse_form_attributes($data, $defaults)) . ">" . $indicator . '</div>';
}
开发者ID:Osub,项目名称:Community-Auth-For-CodeIgniter-3,代码行数:20,代码来源:MY_form_helper.php

示例3: smarty_function_picture

function smarty_function_picture($params, $template)
{
    $src = smarty_plugin_get_variable($params, $template, 'src', true);
    $alt = smarty_plugin_get_variable($params, $template, 'alt');
    $path = smarty_plugin_get_variable($params, $template, 'path');
    $CI =& get_instance();
    $CI->load->helper('image');
    $file = find_file($src, 'static/img/');
    // Try to find the image in static/img
    if ($file == null) {
        // We can't read the file
        $file = find_file($src, 'static/uploads/');
        if ($file == null) {
            $src = 'default.png';
        }
    }
    $size = get_image_size($src);
    $size = $size['width'];
    $attr = $params;
    $medias = array();
    $ret = array();
    $attr['src'] = $src;
    if ($path != '') {
        $attr['path'] = site_url($path);
    }
    $ret[] = '<picture ' . _parse_form_attributes($attr, array()) . ' >';
    foreach ($params as $key => $value) {
        // Check if user has set the customized media
        if (strpos($key, 'media') !== false) {
            $media = str_replace('media', '', $key);
            $medias[] = $media;
            $ret[] = "\t" . '<source src="' . site_url('responsive/size/' . $value . '/' . $src) . '" media="(min-width:' . $media . 'px)">';
            continue;
        }
        $attr[$key] = smarty_plugin_get_variable($params, $template, $key, false);
    }
    if ($path == '') {
        $resolutions = get_ci_config('resolutions');
        foreach ($resolutions as $res) {
            if (array_search($res, $medias) !== false) {
                // If the resolution is already covered
                continue;
            }
            $ret[] = "\t" . '<source src="' . site_url('responsive/size/' . (double) $res / 2880 * (double) $size . '/' . $src) . '" media="(min-width:' . $res . 'px)">';
        }
    }
    $ret[] = "\t" . '<noscript>';
    $ret[] = "\t\t" . '<img src="' . site_url('static/img/' . $src) . '" alt="' . $alt . '">';
    $ret[] = "\t" . '</noscript>';
    $ret[] = '</picture>';
    return implode("\n", $ret);
}
开发者ID:zhaoshengloveqingqing,项目名称:Website,代码行数:52,代码来源:function.picture.php

示例4: chainned_dropdown

function chainned_dropdown($data = '', $options = array(), $selected = array(), $extra = '', $extra_options = '')
{
    $defaults = array();
    if (is_array($data)) {
        if (isset($data['selected'])) {
            $selected = $data['selected'];
            unset($data['selected']);
            // select tags don't have a selected attribute
        }
        if (isset($data['options'])) {
            $options = $data['options'];
            unset($data['options']);
            // select tags don't use an options attribute
        }
    } else {
        $defaults = array('name' => $data);
    }
    is_array($selected) or $selected = array($selected);
    is_array($options) or $options = array($options);
    // If no selected state was submitted we will attempt to set it automatically
    if (empty($selected)) {
        if (is_array($data)) {
            if (isset($data['name'], $_POST[$data['name']])) {
                $selected = array($_POST[$data['name']]);
            }
        } elseif (isset($_POST[$data])) {
            $selected = array($_POST[$data]);
        }
    }
    $extra = _attributes_to_string($extra);
    $extra_options = _attributes_to_string($extra_options);
    $multiple = count($selected) > 1 && stripos($extra, 'multiple') === FALSE ? ' multiple="multiple"' : '';
    $form = '<select ' . rtrim(_parse_form_attributes($data, $defaults)) . $extra . $multiple . ">\n";
    foreach ($options as $key => $val) {
        $key = (string) $key;
        if (is_array($val)) {
            if (empty($val)) {
                continue;
            }
            $form .= '<optgroup label="' . $key . "\">\n";
            foreach ($val as $optgroup_key => $optgroup_val) {
                $sel = in_array($optgroup_key, $selected) ? ' selected="selected"' : '';
                $form .= '<option ' . $extra_options . ' value="' . html_escape($optgroup_key) . '"' . $sel . '>' . (string) $optgroup_val . "</option>\n";
            }
            $form .= "</optgroup>\n";
        } else {
            $form .= '<option ' . $extra_options . ' value="' . html_escape($key) . '"' . (in_array($key, $selected) ? ' selected="selected"' : '') . '>' . (string) $val . "</option>\n";
        }
    }
    return $form . "</select>\n";
}
开发者ID:rdeeceria,项目名称:ci3_chainned_dropdown,代码行数:51,代码来源:dropdown_helper.php

示例5: smarty_block_select

function smarty_block_select($params, $content, $template, &$repeat)
{
    if ($repeat) {
        // Skip the first time
        return;
    }
    $attr = get_attr($params, $template);
    $options = get_default($params, 'options', array());
    $selected = get_default($params, 'selected', array());
    $extra = _parse_form_attributes($attr, array());
    if (count($selected) == 0) {
        $selected = $attr['value'];
    }
    return form_dropdown($attr['name'], $options, $selected, $extra);
}
开发者ID:zhaoshengloveqingqing,项目名称:Website,代码行数:15,代码来源:block.select.php

示例6: smarty_block_figure

function smarty_block_figure($params, $content = '', $template, &$repeat)
{
    if ($repeat) {
        // Skip the start part
        return;
    }
    $src = smarty_plugin_get_variable($params, $template, 'src', true);
    $path = smarty_plugin_get_variable($params, $template, 'path');
    $size = get_image_size($src);
    $size = $size['width'];
    if ($path == '') {
        // If we are using auto resizing, skip the resolutions
        $resolutions = get_ci_config('resolutions');
        foreach ($resolutions as $res) {
            $attr['data-media' . $res] = site_url('responsive/size/' . (double) $res / 2880 * (double) $size . '/' . $src);
        }
    }
    foreach ($params as $key => $value) {
        if ($key == 'path') {
            $attr[$key] = site_url(get_smarty_variable($params, $template, 'path', $value));
            continue;
        }
        if (strpos($key, 'media') !== false) {
            $attr['data-' . $key] = site_url('responsive/size/' . $value . '/' . $src);
        } else {
            $attr[$key] = get_smarty_variable($params, $template, $value, $value);
        }
    }
    $ret = array();
    $ret[] = '<figure ' . _parse_form_attributes($attr, array()) . '>';
    if (isset($attr['action'])) {
        $ret[] = '<a href="' . $attr['action'] . '">';
    }
    $ret[] = '<noscript>';
    $ret[] = '<img src="' . site_url('static/img/' . $src) . '">';
    $ret[] = '</noscript>';
    if (isset($attr['action'])) {
        $ret[] = '</a>';
    }
    $ret[] = '<figcaption>';
    $ret[] = $content;
    $ret[] = '</figcaption>';
    $ret[] = '</figure>';
    return implode("\n", $ret);
}
开发者ID:zhaoshengloveqingqing,项目名称:Ci,代码行数:45,代码来源:block.figure.php

示例7: arras_form_checkbox

function arras_form_checkbox($data = '', $value = '', $checked = FALSE, $extra = '')
{
    $defaults = array('type' => 'checkbox', 'name' => !is_array($data) ? $data : '', 'value' => $value);
    if (is_array($data) and array_key_exists('checked', $data)) {
        $checked = $data['checked'];
        if ($checked == FALSE) {
            unset($data['checked']);
        } else {
            $data['checked'] = 'checked';
        }
    }
    if ($checked == TRUE) {
        $defaults['checked'] = 'checked';
    } else {
        unset($defaults['checked']);
    }
    return "<input " . _parse_form_attributes($data, $defaults) . $extra . " />";
}
开发者ID:heikkiket,项目名称:SKP-Helsinki,代码行数:18,代码来源:functions.php

示例8: smarty_block_select

function smarty_block_select($params, $content, $template, &$repeat)
{
    if ($repeat) {
        // Skip the first time
        return;
    }
    $attr = get_attr($params, $template);
    $field = get_field($params, $template);
    $CI =& get_instance();
    if (isset($field->model)) {
        $CI->load->model($field->model);
        $parent_vars = $template->parent->tpl_vars;
        $form_data = get_form_data($parent_vars);
        $options = widget_select_get_options(get_default($params, 'options', array()), $form_data, $field, $CI->{$field->model});
    } else {
        $options = get_default($params, 'options', array());
    }
    $attr['url'] = current_url();
    if (isset($field->filters)) {
        $hasfield = false;
        $rel = array();
        foreach ($field->filters as $key => $filter) {
            if (isset($filter->field)) {
                $rel[] = $filter->field;
                $hasfield = true;
            }
        }
        if ($hasfield) {
            $attr['data-rel'] = implode(',', $rel);
        }
    }
    if (isset($params['noselectboxit']) && $params['noselectboxit'] != '') {
        $attr["data-no-selectBoxIt"] = true;
    }
    $parent_vars = $template->parent->tpl_vars;
    $form_data = get_form_data($parent_vars);
    $selected = get_default($params, 'selected', array());
    $extra = _parse_form_attributes($attr, array());
    if (count($selected) == 0) {
        $selected = $attr['value'];
    }
    return form_dropdown($attr['name'], $options, $selected, $extra);
}
开发者ID:zhaoshengloveqingqing,项目名称:Ci,代码行数:43,代码来源:block.select.php

示例9: ras_form_dropdown

 /**
  * Returns a properly templated dropdown field.
  *
  * @param string $data    The element name or an array of key/value pairs of
  * all attributes.
  * @param array  $options  Array of options for the drop down list.
  * @param string $selected The selected item or an array of selected items.
  * @param string $label   The label of the element.
  * @param string $extra   Any additional items to include, like Javascript.
  * @param string $tooltip A string for inline help or a tooltip icon.
  *
  * @return string The formatted input element, label tag and wrapping divs.
  */
 function ras_form_dropdown($data, $options = array(), $selected = array(), $label = '', $extra = '', $tooltip = '')
 {
     if (!is_array($data)) {
         $data = array('name' => $data);
     }
     if (!isset($data['id'])) {
         $data['id'] = $data['name'];
     }
     $output = _parse_form_attributes($data, array());
     if (!is_array($selected)) {
         $selected = array($selected);
     }
     // If no selected option was submitted, attempt to set it automatically
     if (count($selected) === 0) {
         // If the name appears in the $_POST array, grab the value
         if (isset($_POST[$data['name']])) {
             $selected = array($_POST[$data['name']]);
         }
     }
     $options_vals = '';
     foreach ($options as $key => $val) {
         $key = (string) $key;
         if (is_array($val) && !empty($val)) {
             $options_vals .= "<optgroup label='{$key}'>" . PHP_EOL;
             foreach ($val as $optgroup_key => $optgroup_val) {
                 $sel = in_array($optgroup_key, $selected) ? ' selected="selected"' : '';
                 $options_vals .= "<option value='{$optgroup_key}'{$sel}>{$optgroup_val}</option>" . PHP_EOL;
             }
             $options_vals .= '</optgroup>' . PHP_EOL;
         } else {
             $sel = in_array($key, $selected) ? ' selected="selected"' : '';
             $options_vals .= "<option value='{$key}'{$sel}>{$val}</option>" . PHP_EOL;
         }
     }
     $error = '';
     if (function_exists('form_error') && form_error($data['name'])) {
         $error = ' error';
         $tooltip = '<span class="help-inline">' . form_error($data['name']) . '</span>';
     }
     return "\n<div class='form-group{$error}'>\n    <label class='col-sm-2 control-label' for='{$data['id']}'>{$label}</label>\n    <div class='col-sm-10'>\n         <select {$output} {$extra}>\n            {$options_vals}\n        </select>\n        {$tooltip}\n    </div>\n</div>";
 }
开发者ID:ras-org,项目名称:ras,代码行数:54,代码来源:MY_form_helper.php

示例10: form_input_date_restrict

 function form_input_date_restrict($data = '', $value = '', $extra = '')
 {
     $defaults = array('type' => 'text', 'name' => !is_array($data) ? $data : '', 'value' => $value);
     return "<input " . _parse_form_attributes($data, $defaults) . $extra . " class=\"datepicker-restrict\"/>";
 }
开发者ID:JeffreyDD,项目名称:webzash,代码行数:5,代码来源:MY_form_helper.php

示例11: form_datelonglabel

 function form_datelonglabel($name, $label, $required = FALSE, $value = '', $data = '')
 {
     $defaults = array('name' => $name, 'id' => $name, 'value' => set_value($name, $value));
     $output = '<div class="control-group' . (form_error($name) ? ' error' : '') . '">';
     $output .= form_label($label, $name, array('class' => 'control-label'));
     $output .= '<div class="controls">';
     $output .= "<input " . _parse_form_attributes($data, $defaults) . " />";
     if ($required) {
         $output .= '<div class="input-append">';
     }
     if ($required) {
         $output .= '<span class="add-on"><i class="icon-asterisk"></i></span></div>';
     }
     $output .= form_error($name, '<span class="help-inline">', '</span>');
     $output .= '</div>';
     $output .= '</div>' . "\r\n";
     return $output;
 }
开发者ID:NaszvadiG,项目名称:ci-beam,代码行数:18,代码来源:MY_form_helper.php

示例12: build_tag

function build_tag($tag, $params, $content)
{
    $attr = array();
    foreach ($params as $key => $value) {
        $attr[$key] = $value;
    }
    $ret = array();
    $ret[] = '<' . $tag . ' ' . _parse_form_attributes($attr, array()) . '>';
    $ret[] = $content;
    $ret[] = '</' . $tag . '>';
    return implode("\n", $ret);
}
开发者ID:zhaoshengloveqingqing,项目名称:Ci,代码行数:12,代码来源:common_helper.php

示例13: form_textarea_formatted

function form_textarea_formatted($data = '', $value = '', $extra = '')
{
    $defaults = array('name' => !is_array($data) ? $data : '', 'cols' => '40', 'rows' => '10');
    $prefix = "<p>";
    $suffix = "</p>";
    if (!is_array($data) or !isset($data['value'])) {
        $val = $value;
    } else {
        $val = $data['value'];
        unset($data['value']);
        // textareas don't use the value attribute
    }
    if (isset($data['label']) && isset($data['id'])) {
        $prefix = $prefix . '<label>' . $data['label'] . '</label>';
    }
    $name = is_array($data) ? $data['name'] : $data;
    return $prefix . "<textarea " . _parse_form_attributes($data, $defaults) . $extra . ">" . form_prep($val, $name) . "</textarea>" . $suffix;
}
开发者ID:kumarsivarajan,项目名称:cse300-group10,代码行数:18,代码来源:MY_form_helper.php

示例14: build_field

    function build_field($field, $label = true, $settings = array())
    {
        //$default = array('name', 'type','settings','class','default','placeholder','id'=>'');
        $fiel = $this->parse_field($field);
        extract($fiel);
        $class = isset($class) && $class ? 'form-control ' . $class : 'form-control';
        if ($label && !$placeholder) {
            do_action('sh_form_before_label', $field);
            echo form_label($placeholder, $name);
            do_action('sh_form_after_label', $field);
        }
        if ($placeholder) {
            $settings['attrs']['placeholder'] = $placeholder;
        }
        $settings['attrs']['class'] = $class;
        $default = sh_set($settings, $name) ? sh_set($settings, $name) : $default;
        switch ($this->type) {
            case "input":
                $html['element'] = form_input(array_merge(array('name' => $name, 'type' => $type, 'value' => '', 'id' => $id), (array) $settings['attrs']));
                break;
            case "dropdown":
                $settings['attrs'] = _parse_form_attributes('', array_merge((array) $settings['attrs'], array('id' => $name)));
                $html['element'] = form_dropdown($name, $options, _WSH()->validation->set_value($name, $default), $settings['attrs']);
                break;
            case "multiselect":
                $size = count($settings['value']) < 10 ? count($settings['value']) * 20 : 220;
                $settings['attrs'] = array_to_string(array_merge((array) $settings['attrs'], array('id' => $field, 'style' => "height:" . $size . "px;")));
                $html['element'] = form_multiselect($field . '[]', $settings['value'], _WSH()->validation->set_value($name, $default_value), $settings['attrs']);
                break;
            case "textarea":
                $settingsvalue = empty($user_settings[$name]) ? sh_set($settings, 'value') : $user_settings[$name];
                $html['element'] = form_textarea(array_merge(array('name' => $name, 'value' => _WSH()->validation->set_value($name, $settingsvalue), 'id' => $name), (array) $settings['attrs']));
                break;
            case "switch":
                $html['element'] = '';
                $checked = sh_set($user_settings, $field) == 'on' ? 'checked="checked"' : '';
                $html['element'] = '<span class="form_style switch"><input type="checkbox" name="' . $field . '" ' . $checked . '></span>';
                break;
            case 'file':
                $html['element'] = '<span class="file_upload">';
                $html['element'] .= form_input(array_merge(array('name' => $field, 'value' => $default_value, 'id' => $field), (array) $settings['attrs'])) . '<input type="file" onchange="this.form.' . $field . '.value = this.value" class="fileUpload" name="' . $field . '_file" id="fileUpload">
									<em>' . __('UPLOAD', THEME_NAME) . '</em>';
                $html['element'] .= '</span>';
                $html['preview'] = '';
                if (sh_set($user_settings, $field)) {
                    $html['preview'] = sh_set($user_settings, $field);
                }
                break;
            case "checkbox":
            case "radio":
                $html['element'] = '<div class="clearfix">';
                foreach ($settings['value'] as $key => $val) {
                    $html['element'] .= form_radio($field, $key, $default_value == $key ? true : '', $settings['attrs']) . '<label class="' . $settings['type'] . ' cont-lable" for="' . $field . '"> ' . $val . '</label>' . '';
                }
                $html['element'] .= '</div>';
                break;
            case "colorbox":
                $html['element'] = form_input(array_merge(array('name' => $field, 'value' => $default_value, 'id' => $field, 'class' => 'nuke-color-field'), (array) $settings['attrs']));
                break;
            case "timepicker":
                $html['element'] = form_input(array_merge(array('name' => $field, 'value' => $default_value, 'id' => $field), (array) $settings['attrs']));
                break;
            case "hidden":
                $html['label'] = '';
                $html['element'] = form_input(array_merge(array('type' => 'hidden', 'name' => $field, 'value' => $default_value, 'id' => $field), sh_set($settings, 'attrs')));
                break;
        }
        do_action('sh_form_before_field', $fiel);
        echo $html['element'];
        do_action('sh_form_after_field', $fiel);
    }
开发者ID:kevintrogers,项目名称:justbkause,代码行数:71,代码来源:forms.php

示例15: form_dropdown

    /**
     * Returns a properly templated date dropdown field.
     *
     * @param string $data     Either a string with the element name, or an array of key/value pairs of all attributes.
     * @param array  $options  Array of options for the drop down list
     * @param string $selected Either a string of the selected item or an array of selected items
     * @param string $label    A string with the label of the element.
     * @param string $extra    A string with any additional items to include, like Javascript.
     * @param string $tooltip  A string for inline help or a tooltip icon
     *
     * @return string A string with the formatted input element, label tag and wrapping divs.
     */
    function form_dropdown($data, $options = array(), $selected = '', $label = '', $extra = '', $tooltip = '', $extra_html = '')
    {
        $defaults = array('name' => !is_array($data) ? $data : '');
        // If name is empty at this point, try to grab it from the $data array
        if (empty($defaults['name']) && is_array($data) && isset($data['name'])) {
            $defaults['name'] = $data['name'];
            unset($data['name']);
        }
        $output = _parse_form_attributes($data, $defaults);
        if (!is_array($selected)) {
            $selected = array($selected);
        }
        // If no selected state was submitted we will attempt to set it automatically
        if (count($selected) === 0) {
            // If the form name appears in the $_POST array we have a winner!
            if (isset($_POST[$data['name']])) {
                $selected = array($_POST[$data['name']]);
            }
        }
        $options_vals = '';
        foreach ($options as $key => $val) {
            $key = (string) $key;
            if (is_array($val) && !empty($val)) {
                $options_vals .= '<optgroup label="' . $key . '">' . PHP_EOL;
                foreach ($val as $optgroup_key => $optgroup_val) {
                    $sel = in_array($optgroup_key, $selected) ? ' selected="selected"' : '';
                    $options_vals .= '<option value="' . $optgroup_key . '"' . $sel . '>' . (string) $optgroup_val . "</option>\n";
                }
                $options_vals .= '</optgroup>' . PHP_EOL;
            } else {
                $sel = in_array($key, $selected) ? ' selected="selected"' : '';
                $options_vals .= '<option value="' . $key . '"' . $sel . '>' . (string) $val . "</option>\n";
            }
        }
        $error = '';
        if (function_exists('form_error')) {
            if (form_error($defaults['name'])) {
                $error = ' error';
                $tooltip = '<span class="help-inline">' . form_error($defaults['name']) . '</span>' . PHP_EOL;
            }
        }
        $label = empty($label) ? isset($data['label']) ? $data['label'] : "" : $label;
        $output = <<<EOL


\t\t<div class="form-group form-group-select2">
\t\t\t<label for="{$defaults['name']}">{$label}</label>
\t\t\t<select id="{$defaults['name']}" class="form-control" {$output} {$extra}>
\t\t\t\t{$options_vals}
\t\t\t</select>
\t\t\t{$extra_html}
\t\t\t{$tooltip}
\t\t</div>

EOL;
        return $output;
    }
开发者ID:caina,项目名称:pando,代码行数:69,代码来源:MY_form_helper.php


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