public function getSelectField($renderApi, $unit, $fieldId, $postRequestValue = null) { $inputName = strlen($renderApi->getFormValue($unit, 'inputName')) > 0 ? $renderApi->getFormValue($unit, 'inputName') : $fieldId; $formField = new \SelectField(); $formField->getElementProperties()->addAttribute("name", $inputName); $formField->getElementProperties()->addAttribute("id", $fieldId); $listOptions = $this->listOptions->getListOptions($renderApi, $unit); if ($listOptions->hasOptions()) { foreach ($listOptions->getOptions() as $option) { /* @var $option \Option */ $optionField = new \OptionField(); $optionField->setContent($option->getName()); $elementProperties = $optionField->getElementProperties(); $elementProperties->addAttribute("value", $option->getValue()); if (is_null($postRequestValue) && $option->isChecked() || $postRequestValue === $option->getValue()) { $elementProperties->addAttribute("selected", null); } $formField->add($optionField); } } if ($this->formSubmit->isValid($renderApi, $unit) && !$this->isValidValue($unit, $postRequestValue)) { $formField->getElementProperties()->addClass('vf__error'); } return $formField; }
/** * */ protected function init() { parent::init(); $this->setLabel('core.layout_media_ratio'); $this->setNote('core.layout_media_ratio_note'); $this->setName('media_ratio'); }
/** * dbSelectField::dbSelectField() * * Public constructor: create a new db selectfield object * * @param object &$oForm: the form where the datefield is located on * @param string $sName: the name of the datefield * @param object $oDb: object of the database handler * @param string $sTable: the table to get the fields from * @param mixed $mFields: array of string with the names of the fields which data we should get * @param string $sExtraSQL: extra SQL statements * @param array $aMergeArray: array of items where the options should be merged with * @return dbSelectField * @access public * @author Teye Heimans */ function dbSelectField(&$oForm, $sName, &$oDb, $sTable, $mFields, $sExtraSQL = null, $aMergeArray = array()) { // call the constructor of the selectfield parent::SelectField($oForm, $sName); // make sure that the fields are set in an array $aFields = !is_array($mFields) ? array($mFields) : $mFields; $this->useArrayKeyAsValue(sizeof($aFields) == 2); // generate the query to retrieve the records $sQuery = 'SELECT ' . implode(', ', $aFields) . ' FROM ' . $oDb->quote($sTable) . ' ' . $sExtraSQL; // get the records and load the options $this->_aOptions = is_array($aMergeArray) ? $aMergeArray : array(); // execute the query $sql = $oDb->query($sQuery); // query succeeded if ($sql) { while ($row = $oDb->getRecord($sql)) { if (sizeof($row) == 1) { $this->_aOptions[] = array_shift($row); } else { $this->_aOptions[array_shift($row)] = array_shift($row); } } } else { trigger_error("Error, could not retrieve records.<br '. FH_XHTML_CLOSE .'>\n" . "Error message: " . $oDb->getError() . "<br '. FH_XHTML_CLOSE .'>\n" . "Query: " . $sQuery, E_USER_WARNING); } }
protected function init() { parent::init(); $this->setLabel('core.layout_grid_tablet'); $this->setNote('core.layout_grid_tablet_note'); $this->setName('grid_sm'); }
protected function init() { parent::init(); $this->setLabel('core.layout_grid_desktop'); $this->setNote('core.layout_grid_desktop_note'); $this->setName('grid_md'); }
protected function init() { parent::init(); $this->setLabel('core.layout_card_border'); $this->setNote('core.layout_card_border_note'); $this->setName('card_border'); }
protected function init() { parent::init(); $this->setLabel('core.layout_grid_mobile'); $this->setNote('core.layout_grid_mobile_note'); $this->setName('grid_xs'); }
protected function init() { parent::init(); $this->setLabel('core.layout_grid_space'); $this->setNote('core.layout_grid_space_node'); $this->setName('card_space'); }
protected function init() { parent::init(); $this->setName('media_position'); $this->setLabel('core.layout_media_render'); $this->setNote('core.layout_media_render_note'); }
public function value() { $value = parent::value(); if (empty($value)) { $time = round(time() / ($this->interval * 60)) * ($this->interval * 60); $value = date($this->format(), $time); } return $value; }
/** * */ protected function init() { parent::init(); $this->setOptionTextKey('core.gender_opt_'); /** * default options * * TODO: options should be configs via admincp */ $this->options = [['value' => 'male'], ['value' => 'female']]; }
public function value() { if ($this->override()) { $value = $this->default(); } else { $value = parent::value(); } if (empty($value)) { $time = round(time() / ($this->interval * 60)) * ($this->interval * 60); $value = date($this->format(), $time); } return $value; }
public function value() { if ($this->override()) { $value = $this->default(); } else { $value = parent::value(); } if (!empty($value)) { if ($value == 'now') { $value = date($this->format(), time()); } $time = round((strtotime($value) - strtotime('00:00')) / ($this->interval() * 60)) * ($this->interval() * 60) + strtotime('00:00'); $value = date($this->format(), $time); } return $value; }
/** * Load the value from the dataobject into this field * * @param DataObjectInterface $record */ public function loadFrom(DataObjectInterface $record) { $fieldName = $this->getName(); if (empty($fieldName) || empty($record)) { return; } $relation = $record->hasMethod($fieldName) ? $record->{$fieldName}() : null; // Detect DB relation or field if ($relation instanceof Relation) { // Load ids from relation $value = array_values($relation->getIDList()); parent::setValue($value); } elseif ($record->hasField($fieldName)) { $value = $this->stringDecode($record->{$fieldName}); parent::setValue($value); } }
/** * @param $bot Bot is the selected bot * @return form Form the form we return */ private function _createDriverForm($bot) { //load up our apps. $authorized = User::$me->getAuthorizedApps()->getAll(); $apps[0] = "None"; foreach ($authorized as $row) { /* @var $e OAuthToken */ $e = $row['OAuthToken']; $apps[$e->id] = $e->getName(); } // load up our drivers $drivers = array('printcore' => 'RepRap Serial Driver', 'dummy' => 'Dummy Driver', 's3g' => 'Makerbot Driver (Experimental)'); $form = new Form('driver'); $form->action = $bot->getUrl() . "/edit"; $form->add(DisplayField::name('title')->label('')->value("<h2>Driver Configuration</h2>")); $form->add(SelectField::name('oauth_token_id')->id('oauth_token_dropdown')->label('Computer')->help('Which computer is this bot connected to? <a href="/apps">Full list in the apps area.</a>')->value($bot->get('oauth_token_id'))->options($apps)->onchange('update_driver_form(this)')); $form->add(SelectField::name('driver_name')->id('driver_name_dropdown')->label('Driver Name')->help('Which driver to use? <a href="/help">More info available in the help area.</a>')->required(true)->value($bot->get('driver_name'))->options($drivers)->onchange('update_driver_form(this)')); // $driver_form = Controller::byName('bot')->renderView('driver_form', array( // 'bot_id' => $bot->id, // 'driver' => $bot->get('driver_name'), // 'token_id' => $bot->get('oauth_token_id') // )); $form->add(RawField::name("driver_edit_area")->value('<div id="driver_edit_area"></div>')); return $form; }
/** * @param $bot Bot is the selected bot * @return form Form the form we return */ private function _createDriverForm($bot) { $form = new Form('driver'); $form->action = $bot->getUrl() . "/edit"; switch ($bot->getStatus()) { case BotState::Idle: case BotState::Offline: case BotState::Error: case BotState::Waiting: break; // We're okay to edit with these states // We're okay to edit with these states default: $form->add(ErrorField::name('error')->value("The bot must be in an idle, offline, error, or waiting state in order to edit the driver config.")); return $form; } //load up our apps. $authorized = User::$me->getAuthorizedApps()->getAll(); $apps[0] = "None"; foreach ($authorized as $row) { /* @var $e OAuthToken */ $e = $row['OAuthToken']; $apps[$e->id] = $e->getName(); } // load up our drivers $drivers = array('printcore' => 'RepRap Serial Driver', 'dummy' => 'Dummy Driver', 's3g' => 'Makerbot Driver (Experimental)'); $form->add(DisplayField::name('title')->label('')->value("<h2>Driver Configuration</h2>")); $form->add(SelectField::name('oauth_token_id')->id('oauth_token_dropdown')->label('Computer')->help('Which computer is this bot connected to? <a href="/apps">Full list in the apps area.</a>')->value($bot->get('oauth_token_id'))->options($apps)->onchange('update_driver_form(this)')); $form->add(SelectField::name('driver_name')->id('driver_name_dropdown')->label('Driver Name')->help('Which driver to use? <a href="/help">More info available in the help area.</a>')->required(true)->value($bot->get('driver_name'))->options($drivers)->onchange('update_driver_form(this)')); $form->add(RawField::name("driver_edit_area")->value('<div id="driver_edit_area"></div>')); return $form; }
/** * @return void */ public function init() { parent::init(); $this->choices = array('AF' => 'Afghanistan', 'AX' => 'Aland Islands', 'AL' => 'Albania', 'DZ' => 'Algeria', 'AS' => 'American Samoa', 'AD' => 'Andorra', 'AO' => 'Angola', 'AI' => 'Anguilla', 'AQ' => 'Antarctica', 'AG' => 'Antigua And Barbuda', 'AR' => 'Argentina', 'AM' => 'Armenia', 'AW' => 'Aruba', 'AU' => 'Australia', 'AT' => 'Austria', 'AZ' => 'Azerbaijan', 'BS' => 'Bahamas', 'BH' => 'Bahrain', 'BD' => 'Bangladesh', 'BB' => 'Barbados', 'BY' => 'Belarus', 'BE' => 'Belgium', 'BZ' => 'Belize', 'BJ' => 'Benin', 'BM' => 'Bermuda', 'BT' => 'Bhutan', 'BO' => 'Bolivia', 'BA' => 'Bosnia And Herzegovina', 'BW' => 'Botswana', 'BV' => 'Bouvet Island', 'BR' => 'Brazil', 'IO' => 'British Indian Ocean Territory', 'BN' => 'Brunei Darussalam', 'BG' => 'Bulgaria', 'BF' => 'Burkina Faso', 'BI' => 'Burundi', 'KH' => 'Cambodia', 'CM' => 'Cameroon', 'CA' => 'Canada', 'CV' => 'Cape Verde', 'KY' => 'Cayman Islands', 'CF' => 'Central African Republic', 'TD' => 'Chad', 'CL' => 'Chile', 'CN' => 'China', 'CX' => 'Christmas Island', 'CC' => 'Cocos (Keeling) Islands', 'CO' => 'Colombia', 'KM' => 'Comoros', 'CG' => 'Congo', 'CD' => 'Congo, Democratic Republic', 'CK' => 'Cook Islands', 'CR' => 'Costa Rica', 'CI' => 'Cote D\'Ivoire', 'HR' => 'Croatia', 'CU' => 'Cuba', 'CY' => 'Cyprus', 'CZ' => 'Czech Republic', 'DK' => 'Denmark', 'DJ' => 'Djibouti', 'DM' => 'Dominica', 'DO' => 'Dominican Republic', 'EC' => 'Ecuador', 'EG' => 'Egypt', 'SV' => 'El Salvador', 'GQ' => 'Equatorial Guinea', 'ER' => 'Eritrea', 'EE' => 'Estonia', 'ET' => 'Ethiopia', 'FK' => 'Falkland Islands (Malvinas)', 'FO' => 'Faroe Islands', 'FJ' => 'Fiji', 'FI' => 'Finland', 'FR' => 'France', 'GF' => 'French Guiana', 'PF' => 'French Polynesia', 'TF' => 'French Southern Territories', 'GA' => 'Gabon', 'GM' => 'Gambia', 'GE' => 'Georgia', 'DE' => 'Germany', 'GH' => 'Ghana', 'GI' => 'Gibraltar', 'GR' => 'Greece', 'GL' => 'Greenland', 'GD' => 'Grenada', 'GP' => 'Guadeloupe', 'GU' => 'Guam', 'GT' => 'Guatemala', 'GG' => 'Guernsey', 'GN' => 'Guinea', 'GW' => 'Guinea-Bissau', 'GY' => 'Guyana', 'HT' => 'Haiti', 'HM' => 'Heard Island & Mcdonald Islands', 'VA' => 'Holy See (Vatican City State)', 'HN' => 'Honduras', 'HK' => 'Hong Kong', 'HU' => 'Hungary', 'IS' => 'Iceland', 'IN' => 'India', 'ID' => 'Indonesia', 'IR' => 'Iran, Islamic Republic Of', 'IQ' => 'Iraq', 'IE' => 'Ireland', 'IM' => 'Isle Of Man', 'IL' => 'Israel', 'IT' => 'Italy', 'JM' => 'Jamaica', 'JP' => 'Japan', 'JE' => 'Jersey', 'JO' => 'Jordan', 'KZ' => 'Kazakhstan', 'KE' => 'Kenya', 'KI' => 'Kiribati', 'KR' => 'Korea', 'XK' => 'Kosovo', 'KW' => 'Kuwait', 'KG' => 'Kyrgyzstan', 'LA' => 'Lao People\'s Democratic Republic', 'LV' => 'Latvia', 'LB' => 'Lebanon', 'LS' => 'Lesotho', 'LR' => 'Liberia', 'LY' => 'Libyan Arab Jamahiriya', 'LI' => 'Liechtenstein', 'LT' => 'Lithuania', 'LU' => 'Luxembourg', 'MO' => 'Macao', 'MK' => 'Macedonia', 'MG' => 'Madagascar', 'MW' => 'Malawi', 'MY' => 'Malaysia', 'MV' => 'Maldives', 'ML' => 'Mali', 'MT' => 'Malta', 'MH' => 'Marshall Islands', 'MQ' => 'Martinique', 'MR' => 'Mauritania', 'MU' => 'Mauritius', 'YT' => 'Mayotte', 'MX' => 'Mexico', 'FM' => 'Micronesia, Federated States Of', 'MD' => 'Moldova', 'MC' => 'Monaco', 'MN' => 'Mongolia', 'ME' => 'Montenegro', 'MS' => 'Montserrat', 'MA' => 'Morocco', 'MZ' => 'Mozambique', 'MM' => 'Myanmar', 'NA' => 'Namibia', 'NR' => 'Nauru', 'NP' => 'Nepal', 'NL' => 'Netherlands', 'AN' => 'Netherlands Antilles', 'NC' => 'New Caledonia', 'NZ' => 'New Zealand', 'NI' => 'Nicaragua', 'NE' => 'Niger', 'NG' => 'Nigeria', 'NU' => 'Niue', 'NF' => 'Norfolk Island', 'MP' => 'Northern Mariana Islands', 'NO' => 'Norway', 'OM' => 'Oman', 'PK' => 'Pakistan', 'PW' => 'Palau', 'PS' => 'Palestinian Territory, Occupied', 'PA' => 'Panama', 'PG' => 'Papua New Guinea', 'PY' => 'Paraguay', 'PE' => 'Peru', 'PH' => 'Philippines', 'PN' => 'Pitcairn', 'PL' => 'Poland', 'PT' => 'Portugal', 'PR' => 'Puerto Rico', 'QA' => 'Qatar', 'RE' => 'Reunion', 'RO' => 'Romania', 'RU' => 'Russian Federation', 'RW' => 'Rwanda', 'BL' => 'Saint Barthelemy', 'SH' => 'Saint Helena', 'KN' => 'Saint Kitts And Nevis', 'LC' => 'Saint Lucia', 'MF' => 'Saint Martin', 'PM' => 'Saint Pierre And Miquelon', 'VC' => 'Saint Vincent And Grenadines', 'WS' => 'Samoa', 'SM' => 'San Marino', 'ST' => 'Sao Tome And Principe', 'SA' => 'Saudi Arabia', 'SN' => 'Senegal', 'RS' => 'Serbia', 'SC' => 'Seychelles', 'SL' => 'Sierra Leone', 'SG' => 'Singapore', 'SK' => 'Slovakia', 'SI' => 'Slovenia', 'SB' => 'Solomon Islands', 'SO' => 'Somalia', 'ZA' => 'South Africa', 'GS' => 'South Georgia And Sandwich Isl.', 'ES' => 'Spain', 'LK' => 'Sri Lanka', 'SD' => 'Sudan', 'SR' => 'Suriname', 'SJ' => 'Svalbard And Jan Mayen', 'SZ' => 'Swaziland', 'SE' => 'Sweden', 'CH' => 'Switzerland', 'SY' => 'Syrian Arab Republic', 'TW' => 'Taiwan', 'TJ' => 'Tajikistan', 'TZ' => 'Tanzania', 'TH' => 'Thailand', 'TL' => 'Timor-Leste', 'TG' => 'Togo', 'TK' => 'Tokelau', 'TO' => 'Tonga', 'TT' => 'Trinidad And Tobago', 'TN' => 'Tunisia', 'TR' => 'Turkey', 'TM' => 'Turkmenistan', 'TC' => 'Turks And Caicos Islands', 'TV' => 'Tuvalu', 'UG' => 'Uganda', 'UA' => 'Ukraine', 'AE' => 'United Arab Emirates', 'GB' => 'United Kingdom', 'US' => 'United States', 'UM' => 'United States Outlying Islands', 'UY' => 'Uruguay', 'UZ' => 'Uzbekistan', 'VU' => 'Vanuatu', 'VE' => 'Venezuela', 'VN' => 'Viet Nam', 'VG' => 'Virgin Islands, British', 'VI' => 'Virgin Islands, U.S.', 'WF' => 'Wallis And Futuna', 'EH' => 'Western Sahara', 'YE' => 'Yemen', 'ZM' => 'Zambia', 'ZW' => 'Zimbabwe'); }
function __construct($name) { parent::__construct($name, array('preset for demo', 'as input', 'png8', 'png24', 'jpeg', 'gif', 'bmp'), null, 'Image format'); }
function CreditCardTypeField($name, $label, $attrs = array(), $required = false) { parent::__construct($name, $label, $attrs, $required); }
/** * @param $file StorageInterface * @param $queue_id int * @return Form */ private function _createJobForm($file, $queue_id) { //load up our queues. $queues = User::$me->getQueues()->getAll(); $qs = array(); foreach ($queues as $row) { /* @var $q Queue */ $q = $row['Queue']; $qs[$q->id] = $q->getName(); } $form = new Form(); $form->add(DisplayField::name('file_name')->label('File')->help('The file that will be printed.')->value($file->getLink())); $form->add(SelectField::name('queue_id')->label('Queue')->help('Which queue are you adding this job to?')->required(true)->options($qs)->value($queue_id)); $form->add(TextField::name('quantity')->label('Quantity')->help('How many copies? Minimum 1, Maximum 100')->required(true)->value(1)); $form->add(CheckboxField::name('priority')->label('Is this a priority job?')->help('Check this box to push this job to the top of the queue')->checked(false)); return $form; }
public function value() { $value = parent::value(); return empty($value) ? site()->user()->username() : parent::value(); }
/** * @param $config SliceConfig * @return Form */ public function _createSliceConfigUploadForm($config) { $form = new Form('upload'); //load up our engines. if (User::isAdmin()) { $engines = SliceEngine::getAllEngines()->getAll(); } else { $engines = SliceEngine::getPublicEngines()->getAll(); } $engs = array(); foreach ($engines as $row) { /* @var $e SliceEngine */ $e = $row['SliceEngine']; $engs[$e->id] = $e->getName(); } $form->add(SelectField::name('engine_id')->label('Slice Engine')->help('Which slicing engine does this config use?')->required(true)->value($config->get('engine_id'))->options($engs)); $form->add(TextField::name('config_name')->label('Config Name')->help('What is the name of this slicing configuration.')->required(true)->value($config->get('config_name'))); if ($config->isHydrated()) { $form->add(CheckboxField::name('expire_slicejobs')->label('Expire Old Slice Jobs')->help('If checked, old slice jobs will be expired and never re-used.')->value(1)); } $form->add(UploadField::name('config_file')->label('Configuration File')->help('The configuration file to use (.ini for Slic3r)')->required(true)); return $form; }
function render () { $this->get_choices(); return parent::render(); }
public function castedCopy($classOrCopy) { $field = parent::castedCopy($classOrCopy); if ($field instanceof SingleSelectField && $this->getHasEmptyDefault()) { $field->setEmptyString($this->getEmptyString()); } return $field; }
public function getAttribs() { unset($this->attr['id']); return parent::getAttribs(); }
/** * FormHandler::selectField() * * Create a selectField on the form * * @param string $title: The title of the field * @param string $name: The name of the field * @param array $options: The options used for the field * @param string $validator: The validator which should be used to validate the value of the field * @param boolean $useArrayKeyAsValue: If the array key's are the values for the options in the field * @param boolean $multiple: Should it be possible to select multiple options ? (Default: false) * @param int $size: The size of the field (how many options are displayed) * @param string $extra: CSS, Javascript or other which are inserted into the HTML tag * @return void * @access public * @author Teye Heimans */ function selectField($title, $name, $options, $validator = null, $useArrayKeyAsValue = null, $multiple = null, $size = null, $extra = null) { require_once FH_INCLUDE_DIR . 'fields/class.SelectField.php'; // options has to be an array if (!is_array($options)) { trigger_error("You have to give an array as value with the selectfield '{$name}'", E_USER_WARNING); return; } // create new selectfield $fld = new SelectField($this, $name); $fld->setOptions($options); if (!empty($validator)) { $fld->setValidator($validator); } if (!is_null($useArrayKeyAsValue)) { $fld->useArrayKeyAsValue($useArrayKeyAsValue); } if (!empty($extra)) { $fld->setExtra($extra); } if ($multiple) { $fld->setMultiple($multiple); } // if the size is given if (!empty($size)) { $fld->setSize($size); } else { if ($multiple) { $fld->setSize(4); } } // register the field $this->_registerField($name, $fld, $title); }
public function input() { return $this->preview() . parent::input(); }
/** * @return void */ public function init() { parent::init(); $this->choices = array('AK' => 'Alaska', 'AL' => 'Alabama', 'AR' => 'Arkansas', 'AZ' => 'Arizona', 'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware', 'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'IA' => 'Iowa', 'ID' => 'Idaho', 'IL' => 'Illinois', 'IN' => 'Indiana', 'KS' => 'Kansas', 'KY' => 'Kentucky', 'LA' => 'Louisiana', 'MA' => 'Massachusetts', 'MD' => 'Maryland', 'ME' => 'Maine', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MO' => 'Missouri', 'MS' => 'Mississippi', 'MT' => 'Montana', 'NC' => 'North Carolina', 'ND' => 'North Dakota', 'NE' => 'Nebraska', 'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NV' => 'Nevada', 'NY' => 'New York', 'OH' => 'Ohio', 'OK' => 'Oklahoma', 'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina', 'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah', 'VA' => 'Virginia', 'VT' => 'Vermont', 'WA' => 'Washington', 'WI' => 'Wisconsin', 'WV' => 'West Virginia', 'WY' => 'Wyoming'); }
/** * @return void */ public function init() { parent::init(); $this->choices = array('BC' => 'British Columbia', 'ON' => 'Ontario', 'NL' => 'Newfoundland and Labrador', 'NS' => 'Nova Scotia', 'PE' => 'Prince Edward Island', 'NB' => 'New Brunswick', 'QC' => 'Quebec', 'MB' => 'Manitoba', 'SK' => 'Saskatchewan', 'AB' => 'Alberta', 'NT' => 'Northwest Territories', 'NU' => 'Nunavut', 'YT' => 'Yukon Territory'); }