/** * Test... * * @param string $expected @todo * @param array $arr @todo * @param string $optKey @todo * @param string $optText @todo * @param null $selected @todo * @param bool $translate @todo * * @return void * * @dataProvider getOptionsData * @since 11.3 */ public function testOptions($expected, $arr, $optKey = 'value', $optText = 'text', $selected = null, $translate = false) { $this->assertEquals($expected, JHtmlSelect::options($arr, $optKey, $optText, $selected, $translate)); // Remove the following lines when you implement this test. $this->markTestIncomplete('This test has not been completely implemented yet.'); }
/** * Tests the JHtmlMenu::menuitems method. * * @return void * * @since 3.1 */ public function testMenuitems() { $this->assertContains('<option value="mainmenu.435">- Home</option>', JHtmlSelect::options(JHtmlMenu::menuitems(), array('published' => '1'))); }
<legend><small><?php echo $this->string('confirm_payment_options'); ?> </legend></small> <div class="control-group"> <label for="ch-confirm_payment_plugin" title="<?php echo $this->string('confirm_payment_plugin_tip'); ?> " class="control-label"><?php echo $this->string('confirm_payment_plugin'); ?> </label> <div class="controls"> <select id="ch-confirm_payment_plugin" name="confirm_payment_plugin"> <?php echo JHtmlSelect::options($this->payment_plugins_list, null, null, $this->config['confirm_payment_plugin']->value, true); ?> </select> </div> </div> </div> </div> </div> </div> <!-- search form --> <div class="tab-pane" id="tab-search_form">
<?php } ?> <?php if ($field->type == 'list') { ?> <select name="<?php echo $option; ?> " id="ch-<?php echo $option; ?> "> <?php echo JHtmlSelect::options($field->list, null, null, $field->value, true); ?> </select> <?php } ?> <?php if ($field->type == 'bool') { ?> <fieldset id="ch-<?php echo $option; ?> " class="radio btn-group btn-group-yesno" > <input type="radio" id="ch-<?php echo $option;
/** * Test the options method. * * @param string $expected Expected generated HTML <option> list. * @param array $arr An array of objects, arrays, or values. * @param mixed $optKey If a string, this is the name of the object variable for * the option value. If null, the index of the array of objects is used. If * an array, this is a set of options, as key/value pairs. Valid options are: * -Format options, {@see JHtml::$formatOptions}. * -groups: Boolean. If set, looks for keys with the value * "<optgroup>" and synthesizes groups from them. Deprecated. Defaults * true for backwards compatibility. * -list.select: either the value of one selected option or an array * of selected options. Default: none. * -list.translate: Boolean. If set, text and labels are translated via * JText::_(). Default is false. * -option.id: The property in each option array to use as the * selection id attribute. Defaults to none. * -option.key: The property in each option array to use as the * selection value. Defaults to "value". If set to null, the index of the * option array is used. * -option.label: The property in each option array to use as the * selection label attribute. Defaults to null (none). * -option.text: The property in each option array to use as the * displayed text. Defaults to "text". If set to null, the option array is * assumed to be a list of displayable scalars. * -option.attr: The property in each option array to use for * additional selection attributes. Defaults to none. * -option.disable: The property that will hold the disabled state. * Defaults to "disable". * -option.key: The property that will hold the selection value. * Defaults to "value". * -option.text: The property that will hold the the displayed text. * Defaults to "text". If set to null, the option array is assumed to be a * list of displayable scalars. * @param string $optText The name of the object variable for the option text. * @param mixed $selected The key that is selected (accepts an array or a string) * @param boolean $translate Translate the option values. * * @return void * * @dataProvider getOptionsData * @since 3.1 */ public function testOptions($expected, $arr, $optKey = 'value', $optText = 'text', $selected = null, $translate = false) { $this->assertEquals($expected, JHtmlSelect::options($arr, $optKey, $optText, $selected, $translate)); }
<h3><?php echo JText::_('COM_FBIMPORTER_IMPORT_AS_COMBINED'); ?> </h3> </div> <div class="modal-body form-horizontal"> <div class="combined-sample control-group"> <label class="combined-sample-lbl control-label" for="combined_sample"><?php echo JText::_('COM_FBIMPORTER_COMBINED_SAMPLE'); ?> </label> <?php $options = array(); $options = JHtmlSelect::options($data->formats, 'id', 'title', $params->get('combined_sample', 2)); ?> <div class="controls"> <select name="combined_sample" id="combined_sample" class=""> <?php echo $options; ?> </select> </div> </div> <div class="combined-catid control-group"> <label for="combined_catid" class="combined-catid-lbl control-label"><?php echo JText::_('JCATEGORY'); ?>
/** * Method to save a record. * * @param string $key The name of the primary key of the URL variable. * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). * * @return boolean True if successful, false otherwise. * @since 11.1 */ public function save($key = null, $urlVar = null) { // Check for request forgeries. JSession::checkToken('GET') or jexit(JText::_('JINVALID_TOKEN')); $app = JFactory::getApplication(); $lang = JFactory::getLanguage(); $model = $this->getModel(); $table = $model->getTable(); $data = JRequest::getVar('jform', array(), 'post', 'array'); $checkin = property_exists($table, 'checked_out'); $context = "{$this->option}.edit.{$this->context}"; $task = $this->getTask(); // Determine the name of the primary key for the data. if (empty($key)) { $key = $table->getKeyName(); } // To avoid data collisions the urlVar may be different from the primary key. if (empty($urlVar)) { $urlVar = $key; } $recordId = JRequest::getInt($urlVar); $session = JFactory::getSession(); $registry = $session->get('registry'); if (!$this->checkEditId($context, $recordId)) { // Somehow the person just went to the form and tried to save it. We don't allow that. $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $recordId)); $this->setMessage($this->getError(), 'error'); $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend(), false)); return false; } // Populate the row id from the session. $data[$key] = $recordId; // Access check. if (!$this->allowSave($data, $key)) { $this->setError(JText::_('JLIB_APPLICATION_ERROR_SAVE_NOT_PERMITTED')); $this->setMessage($this->getError(), 'error'); $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend(), false)); return false; } // Validate the posted data. // Sometimes the form needs some posted data, such as for plugins and modules. $form = $model->getForm($data, false); if (!$form) { $app->enqueueMessage($model->getError(), 'error'); return false; } // Test whether the data is valid. $validData = $model->validate($form, $data); // Check for validation errors. if ($validData === false) { // Get the validation messages. $errors = $model->getErrors(); // Push up to three validation messages out to the user. for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) { if ($errors[$i] instanceof Exception) { $app->enqueueMessage($errors[$i]->getMessage(), 'warning'); } else { $app->enqueueMessage($errors[$i], 'warning'); } } // Save the data in the session. $app->setUserState($context . '.data', $data); // Redirect back to the edit screen. $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($recordId, $key), false)); return false; } // Attempt to save the data. if (!$model->save($validData)) { // Save the data in the session. $app->setUserState($context . '.data', $validData); // Redirect back to the edit screen. $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_SAVE_FAILED', $model->getError())); $this->setMessage($this->getError(), 'error'); $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($recordId, $key), false)); return false; } // Save succeeded, so check-in the record. if ($checkin && $model->checkin($validData[$key]) === false) { // Save the data in the session. $app->setUserState($context . '.data', $validData); // Check-in failed, so go back to the record and display a notice. $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_CHECKIN_FAILED', $model->getError())); $this->setMessage($this->getError(), 'error'); $this->setRedirect('index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($recordId, $key)); return false; } $this->setMessage(JText::_(($lang->hasKey($this->text_prefix . ($recordId == 0 && $app->isSite() ? '_SUBMIT' : '') . '_SAVE_SUCCESS') ? $this->text_prefix : 'JLIB_APPLICATION') . ($recordId == 0 && $app->isSite() ? '_SUBMIT' : '') . '_SAVE_SUCCESS')); // Load saved record $savedRecordId = $model->getState($model->getName() . '.id'); $table->load($savedRecordId); $options = SolidresHelper::getCategoryOptions(); echo json_encode(array('saved' => 'true', 'category_select_html' => JHtmlSelect::options($options, 'value', 'text', $savedRecordId))); die(1); }