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']); }
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); }
/** * 推荐字段类型表单组合处理 * @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']); }
/** * 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>'; }
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); }
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; }
/** * 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; }
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)); }
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>"; }
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])); } }
/** * 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); }
/** * @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()); }
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); }
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); } }
/** * @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); }
public function modal() { $type_group_inputs = [View::forge('form/group/input', ['label_coltype' => 'col-xs-2', 'input_coltype' => 'col-xs-4', 'input' => Form::checkbox('crew', '', boolval($this->requested_person->duty_limitations_enforced), ['class' => 'checkbox', 'data-change' => '[{"target":"target", "action":"showhide"}]']), 'label' => 'Crew member'], false), View::forge('form/group/input', ['label_coltype' => 'col-xs-2', 'input_coltype' => 'col-xs-4', 'input' => Form::checkbox('patient', '', boolval($this->requested_person->include_in_roster), ['class' => 'checkbox']), 'label' => 'Patient'], false)]; // General section $name_group_inputs = [Form::input('person_id', $this->id, ['type' => 'hidden']), View::forge('form/group/input', ['label_coltype' => 'col-xs-2', 'input_coltype' => 'col-xs-4', 'input' => Form::input('first_name', $this->requested_person->first_name, ['class' => 'form-control', 'type' => 'text', 'data-change' => '[{"link":"test", "target":"target", "action":"showhide"}]']), 'label' => 'First Names'], false), View::forge('form/group/input', ['label_coltype' => 'col-xs-2', 'input_coltype' => 'col-xs-4', 'input' => Form::input('last_name', $this->requested_person->last_name, ['class' => 'form-control', 'type' => 'text']), 'label' => 'Last Name'], false)]; $id_group_inputs = [View::forge('form/group/input', ['label_coltype' => 'col-xs-2', 'input_coltype' => 'col-xs-4', 'input' => Form::input('nhi', $this->requested_person->caa_num, ['class' => 'form-control', 'type' => 'number']), 'label' => 'NHI Number'], false), View::forge('form/group/input', ['label_coltype' => 'col-xs-2', 'input_coltype' => 'col-xs-4', 'input' => Form::input('acc', $this->requested_person->asl_num, ['class' => 'form-control', 'type' => 'number']), 'label' => 'ACC Number'], false)]; $weight_group_inputs = [View::forge('form/group/input', ['label_coltype' => 'col-xs-2', 'input_coltype' => 'col-xs-4', 'input' => Form::input('weight', $this->requested_person->weight, ['class' => 'form-control', 'type' => 'number']), 'label' => 'Weight'], false)]; $name_group = View::forge('form/group', ['inputs' => $name_group_inputs], false); $type_group = View::forge('form/group', ['inputs' => $type_group_inputs], false); $id_group = View::forge('form/group', ['inputs' => $id_group_inputs], false); $weight_group = View::forge('form/group', ['inputs' => $weight_group_inputs, 'context' => 'target'], false); // Create "General" section and inputs $general_section_groups = [$name_group, $id_group, $weight_group, $type_group]; $general_section_data = ['heading' => 'General', 'unique_id' => Str::random('uuid'), 'groups' => $general_section_groups]; $general_section = View::forge('form/section', $general_section_data); // End of general section // // Contact section // Create "Contact" section and inputs $email_group_inputs = [View::forge('form/group/input', ['label_coltype' => 'col-xs-2', 'input_coltype' => 'col-xs-4', 'input' => Form::input('email', $this->requested_person->email, ['class' => 'form-control', 'type' => 'email']), 'label' => 'E-mail address'], false)]; $phone_group_inputs = [View::forge('form/group/input', ['label_coltype' => 'col-xs-2', 'input_coltype' => 'col-xs-4', 'input' => Form::input('phone1', $this->requested_person->phone1, ['class' => 'form-control', 'type' => 'text']), 'label' => 'Phone 1 (land)'], false), View::forge('form/group/input', ['label_coltype' => 'col-xs-2', 'input_coltype' => 'col-xs-4', 'input' => Form::input('phone2', $this->requested_person->phone2, ['class' => 'form-control', 'type' => 'text']), 'label' => 'Phone 2 (cell)'], false)]; $address1_group_inputs = [View::forge('form/group/input', ['label_coltype' => 'col-xs-2', 'input_coltype' => 'col-xs-10', 'input' => Form::input('address1', $this->requested_person->address1, ['class' => 'form-control', 'type' => 'text']), 'label' => 'Address Line 1'], false)]; $address2_group_inputs = [View::forge('form/group/input', ['label_coltype' => 'col-xs-2', 'input_coltype' => 'col-xs-10', 'input' => Form::input('address2', $this->requested_person->address2, ['class' => 'form-control', 'type' => 'text']), 'label' => 'Address Line 2'], false)]; $address3_group_inputs = [View::forge('form/group/input', ['label_coltype' => 'col-xs-2', 'input_coltype' => 'col-xs-10', 'input' => Form::input('address3', $this->requested_person->address3, ['class' => 'form-control', 'type' => 'text']), 'label' => 'Address Line 3'], false)]; $address4_group_inputs = [View::forge('form/group/input', ['label_coltype' => 'col-xs-2', 'input_coltype' => 'col-xs-10', 'input' => Form::input('address4', $this->requested_person->address4, ['class' => 'form-control', 'type' => 'text']), 'label' => 'Address Line 4'], false)]; include_once APPPATH . 'views/form/options/countries.php'; $country_group_inputs = [View::forge('form/group/input', ['label_coltype' => 'col-xs-2', 'input_coltype' => 'col-xs-4', 'input' => Form::select('country', $this->requested_person->country, $country_list, ['class' => 'form-control']), 'label' => 'Country'], false)]; // IF THIS IS A NEW PERSON, LOAD THE TREEVIEW AGAIN. $actions_group_inputs = [View::forge('form/button', ['label' => 'Save Changes', 'class' => 'form-control btn-success', 'coltype' => 'col-xs-offset-2 col-xs-2', 'response_target' => 'content/content', 'link' => 'submit/layouts_resources_people/' . $this->id], false), View::forge('form/deletebutton', ['label' => 'Delete Person', 'delete_message' => 'Are you sure you wish to delete the person "' . $this->requested_person->get_name() . '"?', 'callback_function' => 'mark_deleted', 'class' => 'form-control btn-danger', 'coltype' => 'col-xs-offset-4 col-xs-2'], false)]; $email_group = View::forge('form/group', ['inputs' => $email_group_inputs], false); $phone_group = View::forge('form/group', ['inputs' => $phone_group_inputs], false); $address1_group = View::forge('form/group', ['inputs' => $address1_group_inputs], false); $address2_group = View::forge('form/group', ['inputs' => $address2_group_inputs], false); $address3_group = View::forge('form/group', ['inputs' => $address3_group_inputs], false); $address4_group = View::forge('form/group', ['inputs' => $address4_group_inputs], false); $country_group = View::forge('form/group', ['inputs' => $country_group_inputs], false); $actions_group = View::forge('form/group', ['inputs' => $actions_group_inputs], false); $contact_section_groups = [$email_group, $phone_group, $address1_group, $address2_group, $address3_group, $address4_group, $country_group]; $contact_section_data = ['heading' => 'Contact', 'unique_id' => Str::random('uuid'), 'groups' => $contact_section_groups]; $contact_section = View::forge('form/section', $contact_section_data); // Create modal body $modal_content = View::forge('modal/content'); $modal_content->title = "My Profile"; $modal_content->body = View::forge('form/container', ['sections' => [$general_section, $contact_section, $actions_group], 'type' => 'form-horizontal', 'name' => 'person']); // Set modal content to configured content. $modal_large = View::forge('modal/large'); $modal_large->content = $modal_content; // Set the view to the modal container to send back to client. $this->person_form = $modal_large; }
public function input($name, $value, array $attr = NULL) { $model = Sprig::factory($this->model); // All available options $options = $model->select_list($model->pk()); // Convert the selected options $value = $this->value($value); $inputs = array(); foreach ($options as $id => $label) { $inputs[] = '<label>' . Form::checkbox("{$name}[]", $id, isset($value[$id])) . ' ' . $label . '</label>'; } // Hidden input is added to force $_POST to contain a value for // this field, even when nothing is selected. return Form::hidden($name, '') . '<ul><li>' . implode('</li><li>', $inputs) . '</li></ul>'; }
public function getContent() { //@todo automate module simple configuration for Model's columns or settings (conf) if (Input::get('illuminatocomments_conf')) { $this->conf->set(['GRADES' => Input::has('enable_grades')]); $this->conf->set(['COMMENTS' => Input::has('enable_comments')]); } $html = Form::open(['id' => 'illuminatocomments_form', 'enctype' => 'multipart/form-data', 'url' => URL::full()]); $html .= Form::label('enable_grades', 'Enable grades'); $html .= Form::checkbox('enable_grades', '1', $this->conf->get('GRADES')); $html .= Form::label('enable_comments', 'Enable comments'); $html .= Form::checkbox('enable_comments', '1', $this->conf->get('COMMENTS')); $html .= Form::submit('Save', ['name' => 'illuminatocomments_conf', 'id' => 'illuminatocomments_conf']); $html .= Form::close(); return $html; }
/** inheritdoc */ public static function displayForm($value, &$settings, $model) { $include_label = isset($settings['label']) ? $settings['label'] : true; $errors = $model->getErrorsForField($settings['mapping']['fieldName']); $has_errors = count($errors) > 0; $input_attributes = isset($settings['input_attributes']) ? $settings['input_attributes'] : array(); $off_input = \Form::hidden($settings['mapping']['fieldName'], '0'); $input = \Form::checkbox($settings['mapping']['fieldName'], '1', $value, $input_attributes); $title = $settings['title'] . ($has_errors ? ' - ' . $errors[0] : ''); $label = !$include_label ? $input : html_tag('label', array('class' => 'checkbox'), $input . '<span class="item-label"> ' . $title . '</span>'); $description = isset($settings['description']) ? '<span class="help-block">' . $settings['description'] . '</span>' : ''; if (isset($settings['wrap']) && $settings['wrap'] === false) { return $label; } return html_tag('div', array('class' => 'field-type-checkbox controls control-group' . ($has_errors ? ' error' : '')), $off_input . $label . $description) . '<div class="clear"></div>'; }
/** inheritdoc */ public static function displayForm($value, &$settings, $model) { $required = isset($settings['required']) ? $settings['required'] : false; $errors = $model->getErrorsForField($settings['mapping']['fieldName']); $has_errors = count($errors) > 0; $input_attributes = array('class' => 'input input-xxlarge'); $attributes = array('class' => 'field-type-link controls control-group' . ($has_errors ? ' error' : '')); $href_name = $settings['mapping']['fieldName'] . '[href]'; $value['href'] = isset($value['href']) ? $value['href'] : null; $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; } } // EXTERNAL CHECKBOX $external_name = $settings['mapping']['fieldName'] . '[external]'; $external_value = \Arr::get($value, 'external', false); $external = \Form::hidden($external_name, '0') . html_tag('label', array('class' => 'checkbox external-checkbox'), \Form::checkbox($external_name, '1', $external_value, array()) . ' custom'); $label = \Form::label($label_text . ($has_errors ? ' - ' . $errors[0] : ''), $href_name, array('class' => 'item-label')) . $external . html_tag('div', array('class' => 'clear'), ' '); if ($external_value) { $attributes['class'] .= ' external'; } // EXTERNAL INPUT CONTENT $href_value_ext = $external_value ? $value['href'] : ''; $ext_input = \Form::input($href_name, $href_value_ext, $input_attributes); $ext_content = html_tag('div', array('class' => 'external-link'), $ext_input); // INTERNAL DROPDOWN CONTENT $options = static::getOptions($settings, $model); $href_value_int = $external_value ? '' : $value['href']; // Check if the value is actually an alias if (!empty($href_value_int)) { $url_value = \CMF\Model\URL::find($href_value_int); if ($url_value && ($alias = $url_value->alias)) { $href_value_int = $alias->id; } } $input = \Form::select($href_name, $href_value_int, $options, $input_attributes); $int_content = html_tag('div', array('class' => 'internal-link'), $input); return html_tag('div', $attributes, $label . $int_content . $ext_content) . html_tag('div', array(), ''); }
function box($field, $value, $fieldinfo) { extract($fieldinfo); //错误提示 $errortips = $this->fields[$field]['errortips']; if ($minlength) { //验证规则 $this->formValidateRules['info[' . $field . ']'] = array("required" => true); //验证不通过提示 $this->formValidateMessages['info[' . $field . ']'] = array("required" => $errortips ? $errortips : $name . "不能为空!"); } $setting = unserialize($fieldinfo['setting']); if ($value == '') { $value = $setting['defaultvalue']; } $options = explode("\n", $setting['options']); foreach ($options as $_k) { $v = explode("|", $_k); $k = trim($v[1]); $option[$k] = $v[0]; } $values = explode(',', $value); $value = array(); foreach ($values as $_k) { if ($_k != '') { $value[] = $_k; } } $value = implode(',', $value); switch ($setting['boxtype']) { case 'radio': $string = Form::radio($option, $value, "name='info[{$field}]' {$fieldinfo['formattribute']}", $setting['width'], $field); break; case 'checkbox': $string = Form::checkbox($option, $value, "name='info[{$field}][]' {$fieldinfo['formattribute']}", 1, $setting['width'], $field); break; case 'select': $string = Form::select($option, $value, "name='info[{$field}]' id='{$field}' {$fieldinfo['formattribute']}"); break; case 'multiple': $string = Form::select($option, $value, "name='info[{$field}][]' id='{$field} ' size=2 multiple='multiple' style='height:60px;' {$fieldinfo['formattribute']}"); break; } return $string; }
/** inheritdoc */ public static function displayForm($value, &$settings, $model) { $include_label = isset($settings['label']) ? $settings['label'] : true; $target_class = $settings['mapping']['targetEntity']; if (is_null($value) || !$value instanceof $target_class) { $value = new $target_class(); } // Show a simple alias form if the input var is set if (\Input::param('alias', false) !== false) { $linkValue = array(); if (!empty($value)) { $linkValue['href'] = $value->isExternal() ? $value->url : strval($value->id); $linkValue['external'] = $value->isExternal(); } return \CMF\Field\Object\Link::displayForm($linkValue, $settings, $model); } $model_class = get_class($model); $errors = $model->getErrorsForField($settings['mapping']['fieldName']); $has_errors = count($errors) > 0; $attributes = array('class' => 'field-type-url controls control-group' . ($has_errors ? ' error' : '')); $slug_name = $settings['mapping']['fieldName'] . '[slug]'; $label_text = $settings['title'] . ($has_errors ? ' - ' . $errors[0] : ''); if (\CMF::$lang_enabled && !\CMF::langIsDefault()) { if (!$value->hasTranslation('slug')) { $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; } } $keep_updated_setting = 'settings[' . $settings['mapping']['fieldName'] . '][keep_updated]'; $keep_updated = \Form::hidden($keep_updated_setting, '0', array()) . html_tag('label', array('class' => 'checkbox keep-updated'), \Form::checkbox($keep_updated_setting, '1', \Arr::get($settings, 'keep_updated', true), array()) . strtolower(\Lang::get('admin.common.auto_update'))); $input = \Form::input($slug_name, $value->slug, array('class' => 'input-xlarge', 'data-copy-from' => implode(',', $model_class::slugFields()))); $label = !$include_label ? '' : html_tag('label', array('class' => 'item-label', 'for' => $slug_name), $label_text) . $keep_updated . html_tag('div', array('class' => 'clear'), ' '); $prefix = $value->prefix; $prepend = html_tag('span', array('class' => 'add-on'), empty($prefix) ? '/' : $prefix); $input = html_tag('div', array('class' => 'input-prepend'), $prepend . $input); $clear = '<div class="clear"><!-- --></div>'; if (isset($settings['wrap']) && $settings['wrap'] === false) { return $label . $input; } return html_tag('div', $attributes, $label . $input) . $clear; }
function page() { global $db, $session; //did we get passed a userid? $permission = []; if ($_GET['id']) { //build up a user $permissionID = intval($_GET['id']); $permission = $db->from('core_permission_list')->where('id', $permissionID)->fetch(); } $formOptions = array('action' => 'permission.php', 'data' => $permission, 'files' => true, 'title' => 'Permission Setup'); $permissionForm = new Form($formOptions); $options = array('field' => 'displayname', 'label' => "Display name", 'description' => ''); $permissionForm->text($options); $options = array('field' => 'js_varname', 'label' => "JS variable name", 'description' => ''); $permissionForm->text($options); $options = array('field' => 'include_js', 'label' => "Include JS in head", 'description' => ''); $permissionForm->checkbox($options); $permissionForm->generate(); }
/** * Display a list of incoming messages * * @uses Assets::popup * @uses Route::url * @uses Route::get * @uses Route::uri * @uses Request::is_datatables * @uses Form::checkbox * @uses HTML::anchor * @uses Date::formatted_time * @uses HTML::icon * @uses Text::limit_chars */ public function action_inbox() { Assets::popup(); $url = Route::url('user/message', array('action' => 'inbox'), TRUE); $redirect = Route::get('user/message')->uri(array('action' => 'inbox')); $form_action = Route::get('user/message')->uri(array('action' => 'bulk', 'id' => PM::INBOX)); $destination = '?destination=' . $redirect; $is_datatables = Request::is_datatables(); /** @var $messages Model_Message */ $messages = ORM::factory('Message')->loadInbox(); if ($is_datatables) { $this->_datatables = $messages->dataTables(array('id', 'subject', 'sender', 'sent')); foreach ($this->_datatables->result() as $message) { $this->_datatables->add_row(array(Form::checkbox('messages[' . $message->id . ']', $message->id, isset($_POST['messages'][$message->id])), HTML::anchor($message->user->url, $message->user->nick, array('class' => 'message-' . $message->status)), HTML::anchor($message->url, Text::limit_chars($message->subject, 20), array('class' => 'message-' . $message->status)) . ' ' . HTML::anchor($message->url, Text::limit_chars(strip_tags($message->body), 80)), Date::formatted_time($message->sent, 'M d, Y'), HTML::icon($message->delete_url . $destination, 'fa-trash-o', array('title' => __('Delete Message'), 'data-toggle' => 'popup', 'data-table' => '#user-message-inbox')))); } } $this->title = __('Inbox'); $view = View::factory('message/inbox')->bind('datatables', $this->_datatables)->set('is_datatables', $is_datatables)->set('action', $form_action)->set('url', $url); $this->response->body($view); }
public function render() { $render = ''; if (!is_array($this->_config['options'])) { $this->_config['options'] = array_combine($this->_extra[$this->_config['options']], $this->_extra[$this->_config['options']]); } switch ($this->_config['format']) { case 'select': // Multiple if ($this->_config['multiple']) { $render = Form::select($this->_name . '[]', $this->_config['options'], (array) $this->_value, $this->_attributes + array('id' => $this->_id)); break; } // Multichoice if ($this->_config['multichoice']) { $render = ZForm::multichoice($this->_name, $this->_config['options'], $this->_value, $this->_attributes + array('id' => $this->_id)); break; } // Single $render = Form::select($this->_name, $this->_config['options'], $this->_value, $this->_attributes + array('id' => $this->_id)); break; default: $first = true; $i = 0; foreach ($this->_config['options'] as $option => $label) { $render .= '<span class="enum-item">'; $id = $first ? $this->_id : $this->_id . '_' . $i++; // Multiple (checkboxes) if ($this->_config['multiple']) { $render .= Form::checkbox($this->_name . '[' . $option . ']', $option, in_array($option, $this->_value), $this->_attributes + array('id' => $id)); } else { $render .= Form::radio($this->_name, $option, $this->_value == $option or $first and !$this->_value, $this->_attributes + array('id' => $id)); } $render .= Form::label($id, $label); $render .= '</span>'; $first = false; } $render = '<div class="enum">' . $render . '</div>'; } return $render; }
/** @inheritdoc */ public static function displayForm($value, &$settings, $model) { $settings = static::settings($settings); $value = $value instanceof \Doctrine\Common\Collections\Collection && count($value) > 0 ? $value->toArray() : array(); $value_ids = array_map(function ($val) { return $val->id; }, $value); $target_class = $settings['mapping']['targetEntity']; $targets = $target_class::findAll(); $checkboxes = array(); $cols = intval($settings['cols'] ?: 1); $per_col = ceil(count($targets) / $cols); if ($per_col > 10) { $cols = ceil(count($targets) / 10); if ($cols > 4) { $cols = 4; } $per_col = ceil(count($targets) / $cols); } $col_class = $cols ? 'span' . floor(12 / $cols) : 'span12'; $content = ''; $num = 0; $hidden = \Form::hidden($settings['mapping']['fieldName'], null); for ($i = 0; $i < $cols; $i++) { $col_content = ''; for ($j = 0; $j < $per_col; $j++) { if ($num >= count($targets)) { break; } $checkbox = \Form::checkbox($settings['mapping']['fieldName'] . '[]', $targets[$num]->id, in_array($targets[$num]->id, $value_ids)); $col_content .= html_tag('label', array('class' => 'checkbox'), $checkbox . ' ' . $targets[$num]->display()); $num++; } $content .= html_tag('div', array('class' => $col_class), $col_content); } $group_label = html_tag('label', array(), $settings['title']); $group = html_tag('div', array('class' => 'controls control-group checkbox-group'), $hidden . html_tag('div', array('class' => 'row-fluid'), $content)); return html_tag('div', array('class' => 'controls control-group'), $group_label . $group); }
function display_todos($items) { foreach ($items as $todo) { ?> <div> <?php echo Form::checkbox('done', $todo->done, 'onclick="document.location.href=\'' . URL::create('todo', 'checkbox', array('id' => $todo->id)) . '\'"'); ?> <?php echo $todo->description; ?> <?php echo $todo->project->name; ?> <a href="<?php echo URL::create('todo', 'edit', array('id' => $todo->id)); ?> ">Edit</a> <a href="<?php echo URL::create('todo', 'delete', array('id' => $todo->id)); ?> " onclick="return confirm('Are you sure you want to delete this entry: <?php echo $todo->description; ?> ');" > Distroy </a> </div> <br /> <?php } }
public function box($field, $value, $fieldinfo) { $setting = string2array($fieldinfo['setting']); if ($value == '') { $value = $this->fields[$field]['defaultvalue']; } $options = explode("\n", $this->fields[$field]['options']); foreach ($options as $_k) { $v = explode("|", $_k); $k = trim($v[1]); $option[$k] = $v[0]; } $values = explode(',', $value); $value = array(); foreach ($values as $_k) { if ($_k != '') { $value[] = $_k; } } $value = implode(',', $value); switch ($this->fields[$field]['boxtype']) { case 'radio': $string = Form::radio($option, $value, "name='info[{$field}]'", $setting['width'], $field); break; case 'checkbox': $string = Form::checkbox($option, $value, "name='info[{$field}][]'", 1, $setting['width'], $field); break; case 'select': $string = Form::select($option, $value, "name='info[{$field}]' id='{$field}'"); break; case 'multiple': $string = Form::select($option, $value, "name='info[{$field}][]' id='{$field}' size=2 multiple='multiple' style='height:60px;'"); break; } return $string; }
{!! Form::open() !!} <?php isset($request->numOfUsers) ? $n = $request->numOfUsers : ($n = 1); echo Form::selectRange('numOfUsers', 1, 20, $n) . " "; echo Form::label('lNumOfUsers', 'Number of Users'); echo '<br><br>'; isset($request->birthdate) ? $selected = true : ($selected = false); echo Form::checkbox('birthdate', 'birthdate', $selected); echo Form::label('lBirthdate', 'Birthdate'); echo '<br>'; isset($request->address) ? $selected = true : ($selected = false); echo Form::checkbox('address', 'address', $selected); echo Form::label('lAddress', 'Address'); echo '<br>'; isset($request->profile) ? $selected = true : ($selected = false); echo Form::checkbox('profile', 'profile', $selected); echo Form::label('lProfile', 'Profile'); echo '<br><br>'; echo Form::submit('Submit'); ?> {!! Form::close() !!} <p> @if(isset($users)) @foreach($users as $user) <h3> {{ $user->name }} </h3> <?php if (isset($request->birthdate)) { echo '   <b>Birthdate: </b>' . $user->date($format = 'Y-m-d', $max = "now"); echo '<br>';
Form::macro('selectMultipleField', function ($name, $label = null, $options, $value = null, $attributes = array()) { $attributes = array_merge($attributes, ['multiple' => true]); $element = Form::select($name, $options, $value, fieldAttributes($name, $attributes)); return fieldWrapper($name, $label, $element); }); Form::macro('booleanField', function ($name, $label = null, $value = null, $attributes = array()) { $attributes = $attributes + ['class' => 'selectize']; $element = Form::select($name, [null => 'Select One', 1 => 'Enabled', 0 => 'Disabled'], $value, fieldAttributes($name, $attributes)); return fieldWrapper($name, $label, $element); }); Form::macro('checkboxField', function ($name, $label = null, $value = 1, $checked = null, $attributes = array()) { $attributes = array_merge(['id' => 'id-field-' . $name], $attributes); $out = '<div class="checkbox'; $out .= fieldError($name) . '">'; $out .= '<label>'; $out .= Form::checkbox($name, $value, $checked, $attributes) . ' ' . $label; $out .= '</div>'; return $out; }); function fieldWrapper($name, $label, $element) { $out = '<div class="form-group'; $out .= fieldError($name) . '">'; $out .= fieldLabel($name, $label); $out .= $element; $out .= fieldMsg($name); $out .= '</div>'; return $out; } function fieldMsg($field) {