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


PHP options_for_select函数代码示例

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


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

示例1: enum_values_select_tag

/**
* Determines the possible index/value pairs for the given table/field from their
* Peer objects. Sets the selected index to the value in $selected. Returns the
* HTML for a <select> field accordingly.
*/
function enum_values_select_tag($table, $field, $selected = null)
{
    //Load the options
    $options = call_user_func(array($table . 'Peer', 'get' . $field . 's'));
    //Return the select area
    return select_tag(strtolower($table) . '[' . strtolower($field) . ']', options_for_select($options, $selected), array('style' => 'width: 125px'));
}
开发者ID:rayku,项目名称:rayku,代码行数:12,代码来源:EnumHelper.php

示例2: adv_options_for_select

/**
 * Override of the standard options_for_select, that allows the usage of the 'include_zero_custom' option
 * to insert a custom field returning the 0 value on top of the options
 *
 * @return String
 * @author Guglielmo Celata
 **/
function adv_options_for_select($options = array(), $selected = '', $html_options = array())
{
    $html_options = _parse_attributes($html_options);
    if (is_array($selected)) {
        $selected = array_map('strval', array_values($selected));
    }
    $html = '';
    if ($value = _get_option($html_options, 'include_zero_custom')) {
        $html .= content_tag('option', $value, array('value' => '0')) . "\n";
    } else {
        if ($value = _get_option($html_options, 'include_custom')) {
            $html .= content_tag('option', $value, array('value' => '')) . "\n";
        } else {
            if (_get_option($html_options, 'include_blank')) {
                $html .= content_tag('option', '', array('value' => '')) . "\n";
            }
        }
    }
    foreach ($options as $key => $value) {
        if (is_array($value)) {
            $html .= content_tag('optgroup', options_for_select($value, $selected, $html_options), array('label' => $key)) . "\n";
        } else {
            $option_options = array('value' => $key);
            if (is_array($selected) && in_array(strval($key), $selected, true) || strval($key) == strval($selected)) {
                $option_options['selected'] = 'selected';
            }
            $html .= content_tag('option', $value, $option_options) . "\n";
        }
    }
    return $html;
}
开发者ID:valerio-bozzolan,项目名称:openparlamento,代码行数:38,代码来源:AdvancedOptionsForSelectHelper.php

示例3: object_enum_tag

function object_enum_tag($object, $method, $options)
{
    $enumValues = _get_option($options, 'enumValues', array());
    $currentValue = _get_object_value($object, $method);
    $enumValues = array_combine($enumValues, $enumValues);
    return select_tag(_convert_method_to_name($method, $options), options_for_select($enumValues, $currentValue), $options);
}
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:7,代码来源:ObjectDoctrineAdminHelper.php

示例4: options_from_collection_for_select

function options_from_collection_for_select($collection, $valueProp, $textProp, $selected = null)
{
    $set = array();
    foreach ($collection as $entity) {
        $set[$entity->{$textProp}] = $entity->{$valueProp};
    }
    return options_for_select($set, $selected);
}
开发者ID:BackupTheBerlios,项目名称:stato-svn,代码行数:8,代码来源:form_options_helper.php

示例5: testOptionsForSelectWithAssociativeArray

 public function testOptionsForSelectWithAssociativeArray()
 {
     $this->assertDomEqual(options_for_select(array('Margharita' => '7€', 'Calzone' => '9€', 'Napolitaine' => '8€')), '<option value="7€">Margharita</option>
         <option value="9€">Calzone</option>
         <option value="8€">Napolitaine</option>');
     $this->assertDomEqual(options_for_select(array('Margharita' => '7€', 'Calzone' => '9€', 'Napolitaine' => '8€'), '9€'), '<option value="7€">Margharita</option>
         <option value="9€" selected="selected">Calzone</option>
         <option value="8€">Napolitaine</option>');
     $this->assertDomEqual(options_for_select(array('Margharita' => '7€', 'Calzone' => '9€', 'Napolitaine' => '8€'), array('9€', '8€')), '<option value="7€">Margharita</option>
         <option value="9€" selected="selected">Calzone</option>
         <option value="8€" selected="selected">Napolitaine</option>');
 }
开发者ID:BackupTheBerlios,项目名称:stato-svn,代码行数:12,代码来源:form_options_helper.test.php

示例6: select_box

function select_box($name, $choices, $selected = null, $options = array())
{
    $options += array('keys' => true, 'multiple' => false, 'groups' => false);
    $options['name'] = $name;
    $ofs_opts = array('groups' => $options['groups'], 'keys' => $options['keys']);
    unset($options['groups']);
    unset($options['keys']);
    if ($options['multiple']) {
        $selected = (array) $selected;
    }
    return tag('select', options_for_select($choices, $selected, $ofs_opts), $options);
}
开发者ID:jaz303,项目名称:php-helpers,代码行数:12,代码来源:form.php

示例7: sf_simple_cms_slot

function sf_simple_cms_slot($page, $slot, $default_text = null, $default_type = 'Text')
{
    $context = sfContext::getInstance();
    $request = $context->getRequest();
    $culture = $request->getAttribute('culture');
    $slot_object = $page->getSlot($slot, constant(sfConfig::get('app_sfSimpleCMS_escaping_strategy', 'ESC_RAW')));
    if (!$slot_object) {
        $slot_object = new sfSimpleCMSSlot();
        $slot_object->setType($default_type);
        $slot_object->setCulture($culture);
    }
    $slot_value = $slot_object->getValue();
    $slot_type_name = $slot_object->getType();
    $slot_type_class = 'sfSimpleCMSSlot' . $slot_type_name;
    $slot_type = new $slot_type_class();
    if ($request->getParameter('edit') == 'true' && !$request->getParameter('preview')) {
        echo '<div class="editable_slot" title="' . __('Double-click to edit') . '" id="slot_' . $slot . '" onDblClick="Element.show(\'edit_' . $slot . '\');Element.hide(\'slot_' . $slot . '\');">';
        if ($slot_value) {
            // Get slot value from the slot type object
            echo $slot_type->getSlotValue($slot_object);
        } else {
            // default text
            echo $default_text ? $default_text : sfConfig::get('app_sfSimpleCMS_default_text', __('[add text here]'));
        }
        echo '</div>';
        echo form_remote_tag(array('url' => 'sfSimpleCMS/updateSlot', 'script' => 'true', 'update' => 'slot_' . $slot, 'success' => 'Element.show(\'slot_' . $slot . '\');
                        Element.hide(\'edit_' . $slot . '\');
                       ' . visual_effect('highlight', 'slot_' . $slot)), array('class' => 'edit_slot', 'id' => 'edit_' . $slot, 'style' => 'display:none'));
        echo input_hidden_tag('slug', $page->getSlug(), 'id=edit_path' . $slot);
        echo input_hidden_tag('slot', $slot);
        if (sfConfig::get('app_sfSimpleCMS_use_l10n', false)) {
            echo input_hidden_tag('sf_culture', $slot_object->getCulture());
        }
        // Get slot editor from the slot type object
        echo $slot_type->getSlotEditor($slot_object);
        echo label_for('slot_type', __('Type: '));
        echo select_tag('slot_type', options_for_select(sfConfig::get('app_sfSimpleCMS_slot_types', array('Text' => __('Simple Text'), 'RichText' => __('Rich text'), 'Php' => __('PHP code'), 'Image' => __('Image'), 'Modular' => __('List of partials/components'))), $slot_type_name));
        if ($rich = sfConfig::get('app_sfSimpleCMS_rich_editing', false)) {
            // activate rich text if global rich_editing is true and is the current slot is RichText
            $rich = $slot_type_name == 'RichText';
        }
        echo submit_tag('update', array('onclick' => $rich ? 'tinymceDeactivate()' . ';submitForm(\'edit_' . $slot . '\'); return false' : '', 'class' => 'submit_tag'));
        echo button_to_function('cancel', 'Element.hide(\'edit_' . $slot . '\');Element.show(\'slot_' . $slot . '\');', 'class=submit_tag');
        echo '</form>';
    } else {
        echo $slot_type->getSlotValue($slot_object);
    }
}
开发者ID:net7,项目名称:Talia-CMS,代码行数:48,代码来源:sfSimpleCMSHelper.php

示例8: select_date

function select_date ( $year_name, $month_name, $day_name, $min_year, $max_year, $selected_date = NULL )
{
	$selected = explode('-', $selected_date);

	$years = array_merge(array('Select Year'), range($min_year, $max_year));
	$months = indexed_array(array('Select Month', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'));
	$days = array_merge(array('Select Day'), range(1, 31));

	$year_options = options_for_select($years, $selected[0]);
	$month_options = options_for_select($months, $selected[1]);
	$day_options = options_for_select($days, $selected[2]);

	return "<select id='$year_name' name='$year_name'>$year_options</select>"
	     . "<select id='$month_name' name='$month_name'>$month_options</select>"
	     . "<select id='$day_name' name='$day_name'>$day_options</select>";
}
开发者ID:boochtek,项目名称:php-base,代码行数:16,代码来源:form.php

示例9: object_multiselect_language_tag

/**
 * Returns a <selectize> tag populated with all the languages in the world (or almost).
 *
 * The select_language_tag builds off the traditional select_tag function, and is conveniently populated with
 * all the languages in the world (sorted alphabetically). Each option in the list has a two or three character
 * language/culture code for its value and the language's name as its display title.  The country data is
 * retrieved via the sfCultureInfo class, which stores a wide variety of i18n and i10n settings for various
 * countries and cultures throughout the world. Here's an example of an <option> tag generated by the select_country_tag:
 *
 * <samp>
 *  <option value="en">English</option>
 * </samp>
 *
 * <b>Examples:</b>
 * <code>
 *  echo select_language_tag('language', 'de');
 * </code>
 *
 * @param  string $name     field name
 * @param  string $selected selected field values (two or three-character language/culture code)
 * @param  array  $options  additional HTML compliant <select> tag parameters
 *
 * @return string <selectize> tag populated with all the languages in the world.
 * @see select_tag, options_for_select, sfCultureInfo
 */
function object_multiselect_language_tag($name, $selected = null, $options = array())
{
    $c = new sfCultureInfo(sfContext::getInstance()->getUser()->getCulture());
    $languages = $c->getLanguages();
    if ($language_option = _get_option($options, 'languages')) {
        foreach ($languages as $key => $value) {
            if (!in_array($key, $language_option)) {
                unset($languages[$key]);
            }
        }
    }
    asort($languages);
    $option_tags = options_for_select($languages, $selected, $options);
    unset($options['include_blank'], $options['include_custom']);
    return select_tag($name, $option_tags, $options);
}
开发者ID:jonphipps,项目名称:Metadata-Registry,代码行数:41,代码来源:LanguageHelper.php

示例10: select_state_tag

/**
 * Returns a <select> tag populated with all the states in the country.
 *
 * The select_state_tag builds off the traditional select_tag function, and is conveniently populated with 
 * all the states in the default country (sorted alphabetically). Each option in the list has a state code (two-character 
 * for US and Canada) for its value and the state's name as its display title.
 * The options[] array may also contain the following non-html options:
 *   A states[] array containing a list of states to be added in the form array
 * Here's an example of an <option> tag generated by the select_state_tag:
 *
 * <samp>
 *  <option value="NY">New York</option>
 * </samp>
 *
 * <b>Examples:</b>
 * <code>
 *  echo select_state_tag('state', 'NY');
 * </code>
 *
 * @param  string field name 
 * @param  string selected field value (two-character state code)
 * @param  string country (two-character country code)
 * @param  array  additional HTML compliant <select> tag parameters. 
 *                May also include a 'states[]' array containing a list of states to be removed from the list
 *                May also include a 'country' value that will select the states from a country code
 * @return string <select> tag populated with all the states in the default or selected country.
 * @see select_tag, options_for_select
 */
function select_state_tag($name, $value, $options = array())
{
    if (isset($options['country'])) {
        $country = $options['country'];
        unset($options['country']);
    }
    $states = getStates($country);
    if (isset($options['states']) && is_array($options['states'])) {
        foreach ($options['states'] as $key) {
            if (isset($states[$key])) {
                unset($states[$key]);
            }
        }
        unset($options['states']);
    }
    if (isset($options['sort'])) {
        asort($states);
        unset($options['sort']);
    }
    $option_tags = options_for_select($states, $value);
    return select_tag($name, $option_tags, $options);
}
开发者ID:jonphipps,项目名称:Metadata-Registry,代码行数:50,代码来源:StateHelper.php

示例11: date_select

function date_select($name, $value = null, $options = array())
{
    $months = isset($options['months']) ? $options['months'] : array('January' => 1, 'February' => 2, 'March' => 3, 'April' => 4, 'May' => 5, 'June' => 6, 'July' => 7, 'August' => 8, 'September' => 9, 'October' => 10, 'November' => 11, 'December' => 12);
    if (!isset($options['start_year'])) {
        if (isset($value)) {
            $start_year = (int) date('Y', $value) - 10;
        } else {
            $start_year = (int) date('Y') - 10;
        }
    } else {
        $start_year = $options['start_year'];
    }
    $end_year = isset($options['end_year']) ? $options['end_year'] : (int) date('Y');
    $html = '<select name="' . $name . '[m]">';
    $html .= options_for_select($months, (int) (isset($value) ? date('m', $value) : date('m')));
    $html .= '</select> ';
    $html .= '<select name="' . $name . '[d]">';
    $html .= options_for_select(range(1, 31), (int) (isset($value) ? date('d', $value) : date('d')));
    $html .= '</select> ';
    $html .= '<select name="' . $name . '[y]">';
    $html .= options_for_select(range($end_year, $start_year), (int) (isset($value) ? date('Y', $value) : date('Y')));
    $html .= '</select>';
    return $html;
}
开发者ID:pilaf,项目名称:yarr,代码行数:24,代码来源:form.php

示例12: select_tag

                <label for="ff_city">City</label>
                <input type="text" class="text" value="<?php 
echo $city;
?>
" id="ff_city" name="city"/>
                <br clear="left"/>
                <label for="ff_state">State</label>
                <input type="text" class="text" value="<?php 
echo $state;
?>
" id="ff_state" name="state"/>
              </div>
              <div>
                <label for="ff_country">Country</label>
                <?php 
echo select_tag('country', options_for_select($countries, $country, array('include_custom' => '- any -')), array('id' => 'ff_country', 'class' => 'text narrow'));
?>
                <br clear="left"/>
                <label for="ff_county">County</label>
                <input type="text" class="text" value="<?php 
echo $county;
?>
" id="ff_county" name="county"/>
              </div>
              <div>
                <div class="location-as">
                  <ul>
                    <li>
                      <input type="checkbox" id="ff_deceased" value="1" <?php 
if ($deceased) {
    echo 'checked="checked"';
开发者ID:yasirgit,项目名称:afids,代码行数:31,代码来源:findSuccess.php

示例13: testOptions_for_select_function

 /**
  *  Test options_for_select() function
  */
 public function testOptions_for_select_function()
 {
     //  Test choices with none selected
     $this->assertEquals('<option value="0">foo</option>' . "\n" . '<option value="1">bar</option>', options_for_select(array('foo', 'bar')));
     //  Test choices with one selected by key
     $this->assertEquals('<option value="M">mumble</option>' . "\n" . '<option value="G" selected="selected">grumble</option>', options_for_select(array('M' => 'mumble', 'G' => 'grumble'), 'G'));
 }
开发者ID:phpontrax,项目名称:trax,代码行数:10,代码来源:FormOptionsHelperTest.php

示例14: form_error

    echo form_error('sf_asset{type}', array('class' => 'form-error-msg'));
    ?>
      <?php 
}
?>
      <?php 
foreach (sfConfig::get('app_sfAssetsLibrary_types', array('image', 'txt', 'archive', 'pdf', 'xls', 'doc', 'ppt')) as $type) {
    ?>
        <?php 
    $options[$type] = $type;
    ?>
      <?php 
}
?>
      <?php 
echo select_tag('sf_asset[type]', options_for_select($options, $sf_asset->getType()));
?>
    </div>
  </div>

  <?php 
include_partial('sfAsset/edit_form_custom', array('sf_asset' => $sf_asset));
?>

</fieldset>

<?php 
include_partial('edit_actions', array('sf_asset' => $sf_asset));
?>

</form>
开发者ID:rewrewby,项目名称:propertyx,代码行数:31,代码来源:_edit_form.php

示例15: object_select_tag

?>
</td>
					<td class='filter'><?php 
echo object_select_tag(isset($filters['CURRICULUM_ID']) ? $filters['CURRICULUM_ID'] : null, null, array('include_blank' => true, 'related_class' => 'Curriculum', 'text_method' => '__toString', 'control_name' => 'filters[CURRICULUM_ID]', 'peer_method' => 'doSelectFiltered'));
?>
</td>
					<td class='filter'><?php 
echo object_select_tag(isset($filters['ACADEMIC_CALENDAR_ID']) ? $filters['ACADEMIC_CALENDAR_ID'] : null, null, array('include_blank' => true, 'related_class' => 'AcademicCalendar', 'text_method' => '__toString', 'control_name' => 'filters[ACADEMIC_CALENDAR_ID]', 'peer_method' => 'doSelectFiltered'));
?>
</td>
					<td class='filter'><?php 
echo object_select_tag(isset($filters['CLASS_GROUP_ID']) ? $filters['CLASS_GROUP_ID'] : null, null, array('include_blank' => true, 'related_class' => 'ClassGroup', 'peer_method' => 'doSelectOrdered', 'control_name' => 'filters[CLASS_GROUP_ID]'));
?>
					</td>
					<td class='filter'><?php 
echo select_tag('filters[STATUS]', options_for_select(array(Student::STATUS_ACTIVE => __('_STUDENT_STATUS_ACTIVE_'), Student::STATUS_INACTIVE => __('_STUDENT_STATUS_INACTIVE_'), Student::STATUS_OVERDUE => __('_STUDENT_STATUS_OVERDUE_'), Student::STATUS_FINAL => __('_STUDENT_STATUS_FINAL_'), Student::STATUS_GRADUATE => __('_STUDENT_STATUS_GRADUATE_')), isset($filters['STATUS']) ? $filters['STATUS'] : null, array('include_blank' => true)));
?>
</td>
				</tr>
			</thead>
			<tbody>
			<?php 
if ($pager->getNbResults() < 1) {
    ?>
				<tr class="list">
					<td colspan="100">
					<div class="no_record"><?php 
    echo __('No record found');
    ?>
</div>
					</td>
开发者ID:taryono,项目名称:school,代码行数:31,代码来源:listStudentSuccess.php


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