本文整理汇总了PHP中Form::checkbox方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::checkbox方法的具体用法?PHP Form::checkbox怎么用?PHP Form::checkbox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Form
的用法示例。
在下文中一共展示了Form::checkbox方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: posid
function posid($field, $value, $fieldinfo)
{
$setting = unserialize($fieldinfo['setting']);
//推荐位缓存
$position = F("Position");
if (empty($position)) {
return '';
}
$array = array();
foreach ($position as $_key => $_value) {
if ($_value['modelid'] && $_value['modelid'] != $this->modelid || $_value['catid'] && strpos(',' . $this->categorys[$_value['catid']]['arrchildid'] . ',', ',' . $this->catid . ',') === false) {
continue;
}
$array[$_key] = $_value['name'];
}
$posids = array();
if (ACTION_NAME == 'edit') {
$this->position_data_db = M('Position_data');
$result = $this->position_data_db->where(array('id' => $this->id, 'modelid' => $this->modelid))->getField("posid,id,catid,posid,module,modelid,thumb,data,listorder,expiration,extention,synedit");
$posids = implode(',', array_keys($result));
} else {
$posids = $setting['defaultvalue'];
}
return "<input type='hidden' name='info[{$field}][]' value='-1'>" . Form::checkbox($array, $posids, "name='info[{$field}][]'", '', $setting['width']);
}
示例2: _makeInput
protected function _makeInput()
{
$attr = $this->_html_attr;
$attr['class'] = $this->css_class();
$attr['type'] = $this->field_type();
return Form::checkbox($this->name(), null, (bool) $this->value(), $attr);
}
示例3: posid
/**
* 推荐字段类型表单组合处理
* @param type $field 字段名
* @param type $value 字段内容
* @param type $fieldinfo 字段配置
* @return string
*/
function posid($field, $value, $fieldinfo)
{
//扩展配置
$setting = unserialize($fieldinfo['setting']);
//推荐位缓存
$position = cache('Position');
if (empty($position)) {
return '';
}
$array = array();
foreach ($position as $_key => $_value) {
//如果有设置模型,检查是否有该模型
if ($_value['modelid'] && !in_array($this->modelid, explode(',', $_value['modelid']))) {
continue;
}
//如果设置了模型,又设置了栏目
if ($_value['modelid'] && $_value['catid'] && !in_array($this->catid, explode(',', $_value['catid']))) {
continue;
}
//如果设置了栏目
if ($_value['catid'] && !in_array($this->catid, explode(',', $_value['catid']))) {
continue;
}
$array[$_key] = $_value['name'];
}
$posids = array();
if (ACTION_NAME == 'edit') {
$result = M('PositionData')->where(array('id' => $this->id, 'modelid' => $this->modelid))->getField("posid,id,catid,posid,module,modelid,thumb,data,listorder,expiration,extention,synedit");
$posids = implode(',', array_keys($result));
} else {
$posids = $setting['defaultvalue'];
}
return "<input type='hidden' name='info[{$field}][]' value='-1'>" . \Form::checkbox($array, $posids, "name='info[{$field}][]'", '', $setting['width']);
}
示例4: contentListThumbnail
/**
* Snippet for displaying the selection/thumbnail column
*
* @param int $id
* @param string $thumbnail
* @return string
*/
public function contentListThumbnail($id, $thumbnail = '')
{
if (!empty($thumbnail)) {
$thumbnail = '<div class="content-list__thumbnail">' . $thumbnail . '</div>';
}
return '<td class="content-list__cell content-list__cell--thumbnail">' . \Form::checkbox('selected[]', $id, false, ['class' => 'content-list__checkbox']) . $thumbnail . '</td>';
}
示例5: render
public function render()
{
$attributes = $this->get_attributes();
$attributes['id'] = $this->get_name();
$attributes['class'] = 'form-change';
return Form::checkbox($this->get_name(), '1', $this->get_value()->get_raw(), $attributes);
}
示例6: input
public function input($name, $value, array $attr = NULL)
{
$checkbox = Form::checkbox($name, 1, $this->value($value), $attr);
if ($this->append_label) {
$checkbox = "<label>{$checkbox} {$this->label}</label>";
}
return $checkbox;
}
示例7: render_header
/**
* Render Header
*
* Renders the header of a column
*
* @access public
* @param Spark\Grid_Column_Header Header
* @return Spark\Grid_Column_Renderer_Interface
*/
public function render_header(\Grid_Column_Header $header)
{
// Build a checkbox
$checkbox = \Form::checkbox(null, 1, array('targets' => ($name = $header->get_column()->get_name()) ? $name : $header->get_column()->get_identifier() . '[]'));
// Set the rendered value
$header->set_rendered_value(html_tag('span', array('class' => 'header-checkbox'), $checkbox));
return $this;
}
示例8: render_input
public function render_input()
{
$params = $this->params();
$value = 1;
if (isset($params['value'])) {
$value = $params['value'];
}
return Form::checkbox($this->name(), $value, $this->value() == $value, array_diff_key(array('value' => 1), $params));
}
示例9: li_checkbox
public static function li_checkbox($input, $text, $checked = FALSE, array $attributes = array(), $error = "")
{
$atts = array_merge($attributes, array('id'=>$input));
echo "<li class=\"input_field input_text\">";
echo Form::label($input, $text);
echo Form::checkbox($input, NULL, $checked, $atts);
echo "<span class=\"error\">$error</span>";
echo "</li>";
}
示例10: addControls
protected function addControls($model = NULL)
{
$this->addControl(\Easy\Form\Textbox::make('achizitii::~layouts.form.controls.textboxes.textbox')->name('nume')->caption('Titlu template (1)')->placeholder('Titlu template')->class('form-control data-source')->controlsource('nume')->controltype('textbox')->maxlength(255))->addControl(\Easy\Form\Textbox::make('achizitii::~layouts.form.controls.textboxes.textbox')->name('cod_procedura')->caption('Cod procedură (2)')->placeholder('Cod procedură')->class('form-control data-source')->controlsource('cod_procedura')->controltype('textbox')->maxlength(255))->addControl(\Easy\Form\Textbox::make('achizitii::~layouts.form.controls.textboxes.textbox')->name('descriere_procedura')->caption('Descriere procedură (3)')->placeholder('Descriere procedură')->class('form-control data-source')->controlsource('descriere_procedura')->controltype('textbox')->maxlength(255))->addControl(\Easy\Form\Combobox::make('achizitii::~layouts.form.controls.comboboxes.combobox')->name('tip_achizitor')->caption('Tip achizitor (4)')->class('form-control data-source input-group form-select init-on-update-delete_')->controlsource('tip_achizitor')->controltype('combobox')->enabled('false')->options(\Binaryk\Models\Nomenclator\Tip::achizitori()))->addControl(\Easy\Form\Combobox::make('achizitii::~layouts.form.controls.comboboxes.combobox')->name('tip_contract')->caption('Tip contract (5)')->class('form-control data-source input-group form-select init-on-update-delete')->controlsource('tip_contract')->controltype('combobox')->enabled('false')->options(\Binaryk\Models\Nomenclator\Tip::contract()))->addControl(\Easy\Form\Combobox::make('achizitii::~layouts.form.controls.comboboxes.combobox')->name('tip_procedura')->caption('Tip procedură (6)')->class('form-control data-source input-group form-select')->controlsource('tip_procedura')->controltype('combobox')->enabled('false')->options(['0' => '-- Selectați mai întîi [tip achizitor] --']))->addControl(\Easy\Form\Combobox::make('achizitii::~layouts.form.controls.comboboxes.combobox')->name('tip_anunt')->caption('Tip anunț (7)')->class('form-control data-source input-group form-select')->controlsource('tip_anunt')->controltype('combobox')->enabled('false')->options(['0' => '-- Selectați mai întîi [tip procedura] --']))->addControl(\Easy\Form\Combobox::make('achizitii::~layouts.form.controls.comboboxes.combobox')->name('plafon_maxim')->caption('Plafon maxim (8)')->class('form-control data-source input-group form-select init-on-update-delete')->controlsource('plafon_maxim')->controltype('combobox')->enabled('false')->options(['' => '', '5000' => '5.000', '30000' => '30.000', '100000' => '100.000', '130000' => '130.000', '200000' => '200.000', '5000000' => '5.000.000']))->addControl(\Easy\Form\Textbox::make('achizitii::~layouts.form.controls.textboxes.textbox-addon')->name('data_semnare_cf')->caption('Data semnare CF (9)')->placeholder('Data semnare CF')->class('form-control data-source')->readonly(1)->controlsource('data_semnare_cf')->controltype('textbox')->addon(['before' => '<i class="fa fa-calendar"></i>', 'after' => NULL]));
$items = \Binaryk\Models\Nomenclator\TipAchizitii::orderBy('id')->get();
//
foreach ($items as $i => $record) {
$this->addControl(\Easy\Form\Textbox::make('achizitii::~layouts.form.controls.textboxes.textbox-addon')->caption('')->name('txt-tip-achizitii')->placeholder('Textbox')->value($record->nume)->class('form-control input-sm')->enabled(0)->addon(['before' => \Form::checkbox('tip-achizitii-' . $record->id, '1', false, ['class' => 'data-source tipuri-achizitii', 'id' => 'tip-achizitii-' . $record->id, 'data-control-source' => 'tip_achizitii_' . $record->id, 'data-control-type' => 'checkbox', 'data-on' => 1, 'data-off' => 0]), 'after' => NULL]));
}
}
示例11: displayForm
/**
* Renders the field's form element for editing in the admin site
* @see \Admin::getFieldSettings()
* @param mixed $value The current value of the property, if there is one
* @param array $settings Field settings, created through \Admin::getFieldSettings()
* @param object $model The model, if it is being edited.
* @return string The form control
*/
public static function displayForm($value, &$settings, $model)
{
$class = get_called_class();
$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');
$input_attributes['class'] .= ' form_' . $settings['mapping']['fieldName'];
$attributes = array('class' => 'controls control-group' . ($has_errors ? ' error' : '') . ' field-type-' . $class::type($settings));
$label_text = $settings['title'] . ($required ? ' *' : '');
// Translation?
if (\CMF::$lang_enabled && !\CMF::langIsDefault() && isset($settings['mapping']['columnName']) && $model->isTranslatable($settings['mapping']['columnName'])) {
// If there is no translation
if (!$model->hasTranslation($settings['mapping']['columnName'])) {
$attributes['class'] .= ' no-translation';
$input_attributes['class'] .= ' no-translation';
$label_text = '<img class="lang-flag" src="' . \Uri::create('/admin/assets/img/lang/' . \CMF::defaultLang() . '.png') . '" /> ' . $label_text;
} else {
$label_text = '<img class="lang-flag" src="' . \Uri::create('/admin/assets/img/lang/' . \CMF::lang() . '.png') . '" /> ' . $label_text;
}
}
// Description?
$description = isset($settings['description']) ? '<span class="help-block">' . $settings['description'] . '</span>' : '';
// Build the input
$input = '<input type="text" name="' . $settings['mapping']['fieldName'] . '[place_name]" ' . array_to_attr($input_attributes) . ' value="' . \Security::htmlentities(strval($value['place_name']), ENT_QUOTES) . '" />';
$input .= '<input type="hidden" data-ref="place-id" name="' . $settings['mapping']['fieldName'] . '[place_id]" ' . array_to_attr($input_attributes) . ' value="' . \Security::htmlentities(strval($value['place_id']), ENT_QUOTES) . '" />';
$input .= '<input type="hidden" data-ref="address_components" name="' . $settings['mapping']['fieldName'] . '[address_components]" ' . array_to_attr($input_attributes) . ' value="' . \Security::htmlentities(strval($value['address_components']), ENT_QUOTES) . '" />';
// Build the label
$label = !$include_label ? '' : html_tag('label', array('class' => 'item-label', 'for' => $settings['mapping']['fieldName']), $label_text . ($has_errors ? ' - ' . $errors[0] : ''));
// Prepend or append things...
if (isset($settings['prepend'])) {
$input = html_tag('div', array('class' => 'input-prepend'), html_tag('span', array('class' => 'add-on'), $settings['prepend']) . $input);
}
if (isset($settings['append'])) {
$input = html_tag('div', array('class' => 'input-append'), $input . html_tag('span', array('class' => 'add-on'), $settings['append']));
}
// Don't wrap the input if wrap is set to false
if (isset($settings['wrap']) && $settings['wrap'] === false) {
return $label . $input;
}
// Add the 'keep updated' control if the field has a template
if (isset($settings['template']) && !empty($settings['template'])) {
$attributes['class'] .= ' field-with-controls field-with-template';
$auto_update_setting = 'settings[' . $settings['mapping']['fieldName'] . '][auto_update]';
$auto_update_content = \Form::hidden($auto_update_setting, '0', array()) . html_tag('label', array('class' => 'checkbox auto-update-label'), \Form::checkbox($auto_update_setting, '1', \Arr::get($settings, 'auto_update', true), array('class' => 'auto-update')) . strtolower(\Lang::get('admin.common.auto_update')));
$auto_update = html_tag('div', array('class' => 'controls-top'), $auto_update_content);
$label .= $auto_update;
return array('content' => html_tag('div', $attributes, $label . $description . $input) . '<div class="clear"><!-- --></div>', 'widget' => false, 'assets' => array('js' => array('/admin/assets/js/twig.min.js', '/admin/assets/js/fields/template.js')), 'js_data' => $settings);
}
return html_tag('div', $attributes, $label . $description . $input);
}
示例12: testGetCheckboxesHidden
/**
* @covers Form::getCheckboxesHidden
*/
public function testGetCheckboxesHidden()
{
$cb = $this->myForm->getCheckboxesHidden();
$this->assertEmpty($cb->getValue());
$this->myForm->checkbox('choice');
$cb = $this->myForm->getCheckboxesHidden();
$this->assertInstanceOf('Hidden', $cb);
$this->assertEquals('_checkboxes', $cb->getName());
$this->myForm->checkbox('resolution');
$cb = $this->myForm->getCheckboxesHidden();
$this->assertEquals('choice;resolution;', $cb->getValue());
}
示例13: page
function page()
{
global $db, $session;
//lets get a user
$user = $db->from('users')->where('id', 1);
$formOptions = array('action' => $_SERVER['PHP_SELF'], 'id' => 'testForm', 'data' => $user, 'files' => true, 'class' => 'form-horizontal', 'sidebar' => true, 'title' => '', 'description' => '');
$form = new Form($formOptions, $session);
$sidebar = array('class' => 'warning', 'title' => 'Be careful!', 'body' => 'Be sure you complete all fields');
$form->setSidebar($sidebar);
$emailValidation = array('required' => 'true', 'error' => 'Please supply a valid email address');
$email = array('field' => 'email', 'label' => "Email", 'description' => '', 'validation' => $emailValidation);
$form->email($email);
$firstNameValidation = array();
$firstName = array('field' => 'firstname', 'label' => "First Name", 'description' => '', 'validation' => $firstNameValidation);
$form->text($firstName);
$lastName = array('field' => 'lastname', 'label' => "Last Name", 'description' => 'Fill in your last name');
$form->text($lastName);
$taName = array('field' => 'descriptionField', 'label' => "Last Name", 'description' => 'Fill in your last name');
$form->textarea($taName);
$phoneOptions = array('field' => 'phone', 'label' => "Phone", 'description' => 'Home Phone');
$form->phone($phoneOptions);
$checkOptions = array('field' => 'checkTest', 'label' => "Check here", 'description' => 'You authorize everything');
$form->checkbox($checkOptions);
$passwordValidation = array('pattern' => '(?=^.{6,}$)((?=.*\\d)|(?=.*\\W+))(?![.\\n])(?=.*[A-Z])(?=.*[a-z]).*$');
$passwordOptions = array('field' => 'password', 'label' => "Password", 'description' => 'Enter a password at least 6 characters, with at least one symbol and number.', 'validation' => $passwordValidation);
$form->password($passwordOptions);
/*
$dateValidation = array('disabledDays'=>'0,1','disabledDates'=>array("11/23/2015", "12/25/2015"), 'minDate'=>'11/1/2015', 'maxDate'=>'1/30/2016');
$secondDateValidation = array('disabledDays'=>'0,1','disabledDates'=>array("11/23/2015", "12/25/2015"), 'minDate'=>'11/1/2015', 'maxDate'=>'1/30/2016');
$dateOptions = array('field'=>'startdate', 'label'=>'Start/Stop Dates', 'description' =>'Enter a start and stop date', 'validation' => $dateValidation,
'second_field'=>'enddate', 'second_validation' => $secondDateValidation );
$form->date($dateOptions);
$timeValidation = array('stepping'=>5,'disabledDays'=>'0,1','disabledDates'=>array("11/23/2015", "12/25/2015"), 'minDate'=>'11/1/2015', 'maxDate'=>'1/30/2016');
$secondTimeValidation = array('disabledDays'=>'0,1','disabledDates'=>array("11/23/2015", "12/25/2015"), 'minDate'=>'11/1/2015', 'maxDate'=>'1/30/2016');
$dateOptions = array('field'=>'starttime', 'label'=>'Start/Stop Times', 'description' =>'Enter a start and stop time', 'validation' => $timeValidation,
'second_field'=>'endtime', 'second_validation' => $secondTimeValidation );
$form->time($dateOptions);
*/
$timeValidation = array('stepping' => 5, 'disabledDays' => '0,1', 'disabledDates' => array("11/23/2015", "12/25/2015"), 'minDate' => '11/1/2015', 'maxDate' => '1/30/2016');
$secondTimeValidation = array('stepping' => 5, 'disabledDays' => '0,1', 'disabledDates' => array("11/23/2015", "12/25/2015"), 'minDate' => '11/1/2015', 'maxDate' => '1/30/2016');
$dateOptions = array('field' => 'startdatetime', 'label' => 'Start/Stop Date Times', 'description' => 'Enter a start and stop date time', 'validation' => $timeValidation, 'second_field' => 'enddatetime', 'second_validation' => $secondTimeValidation);
$form->datetime($dateOptions);
$options = array('field' => 'department', 'options' => array(0 => 'Advertising', 1 => "Circulation", 2 => 'Production'), 'label' => 'Department', 'description' => 'Select your department');
$form->select($options);
$options = array('field' => 'publications', 'url' => '/ajax/forms/publications.php', 'label' => 'Publication', 'description' => 'Select a publication');
$form->remoteSelect($options);
$form->generate();
//var_dump($this->formScripts);
//grab any form scripts and append them to the global scripts array
$GLOBALS['scripts'] = array_merge($GLOBALS['scripts'], $form->formScripts);
}
示例14: buildControl
public function buildControl($type, $name, $value = null, $attibutes = array(), $options = array())
{
switch ($type) {
case 'select':
return \Form::select($name, $options, $value, $attributes);
case 'password':
return \Form::password($name);
case 'checkbox':
return \Form::checkbox($name);
default:
return \Form::input($type, $name, $value);
}
}
示例15: smarty_function_form_checkbox
/**
* @param array $params
* @param Smarty_Internal_Template $smarty
*
* @throws SmartyException
* @return string
*
* @author Kovács Vince
*/
function smarty_function_form_checkbox($params, Smarty_Internal_Template &$smarty)
{
if (!isset($params['_name'])) {
throw new SmartyException('Missing _name attribute for form_checkbox tag');
}
$name = $params['_name'];
$value = isset($params['_value']) ? $params['_value'] : null;
$checked = isset($params['_checked']) ? (bool) $params['_checked'] : (isset($params['_populate']) && $params['_populate'] ? (bool) \Input::get($name) : null);
unset($params['_name']);
unset($params['_value']);
unset($params['_checked']);
return Form::checkbox($name, $value, $checked, $params);
}